Why does this compile?

George Mitchell george+freebsd at m5p.com
Tue Sep 26 04:55:45 UTC 2017


On 09/26/17 00:38, Russell Haley wrote:
> [...]
> #include <netinet/in.h>
> 
> int main()
> {
>     struct in_pktinfo;
>     return 0;
> }
> [...]

This is a perfectly valid forward declaration of a struct type.  In
most normal cases, you would follow this up with something that contains
a pointer to a thing of that type, and later a full declaration of the
type.  As it stands, though, it's simply a statement to the compiler
that you are possibly using (and fully declaring) the structure type
later on in your program.                                 -- George

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freebsd.org/pipermail/freebsd-arm/attachments/20170926/3e03c9d0/attachment.sig>


More information about the freebsd-arm mailing list