Tutorial :struct ip_mreq disappears when compiling with -std=c99


On some of our linux boxes compiling with gcc -std=c99 makes struct ip_mreq disappear (included from netinet/in.h)

Is there some other interface we are supposed to use ?


Try --std=gnu99.

The default for GCC is '--std=gnu89' which means C89 with GNU extensions. By selecting '--std=c99' you are enabling C99, but disabling the GNU extensions. '--std=gnu99' will select both C99 and GNU extensions support, giving you the best of both worlds.


I don't think there's another interface pre-c99. You may be able to use this with -std=c99 if you add the following at the top of your source(s):

#define __EXTENSIONS__  

but a better way is probably

#define _XOPEN_SOURCE  

Please note that I haven't confirmed.


I am having the same problem. Everything compiles fine using gcc when I do not provide "-std=c99", but when the flag is included, the compiler fails saying that the field with type 'struct ip_mreq' "has incomplete type."

This is a problem since I am dependent on some C99 features.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »