Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 25 Sep 2017 21:54:26 -0700
From:      Bakul Shah <bakul@bitblocks.com>
To:        Russell Haley <russ.haley@gmail.com>
Cc:        freebsd-arm <freebsd-arm@freebsd.org>
Subject:   Re: Why does this compile?
Message-ID:  <20170926045441.BB745156E523@mail.bitblocks.com>
In-Reply-To: Your message of "Mon, 25 Sep 2017 21:38:33 -0700." <CABx9NuSzSzK87WF07S0B2aZpddKxYJf69kR2gWqBmHxaEQO6JA@mail.gmail.com>
References:  <CABx9NuSzSzK87WF07S0B2aZpddKxYJf69kR2gWqBmHxaEQO6JA@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 25 Sep 2017 21:38:33 -0700 Russell Haley <russ.haley@gmail.com> wrote:
Russell Haley writes:
> 
> int main()
> {
>     struct in_pktinfo;
>     return 0;
> }
> 
> This compiles on FreeBSD current and apparently on 11 too. That's a
> bad thing because it's supposed to fail. I checked in.h and there is
> no struct for in_pktinfo. Not surprisingly, if I remove the include
> altogether, it still compiles.
> 
> I assume then that the original author made a mistake? My C is too
> weak and most of my searches don't turn up anything close to what I'm
> looking for.
> 
> Any suggestions would be awesome.  :)

C allows struct forward references. Mainly so that you can
declare pointers to them (and the actual struct defn may be in
another file). As long as you don't dereference such a ptr in
the first file, the cmompiler won't throw a fit.

If you want to generate an error, create a variable in main():

	struct in_pktinfo foo;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20170926045441.BB745156E523>