Linux issues with <net/if.h> and <linux/if.h>

Mike Frysinger vapier@gentoo.org
Sat Aug 11 03:10:00 GMT 2012


On Friday 10 August 2012 16:40:43 Philip Prindeville wrote:
> I'm working on the networking code for Poco on Centos 6.2, and am in a
> situation where I need to use both <net/if.h> and <linux/if.h> in the same
> source file.

generally speaking, if you're using the C library API, then stick to net/*.  
if you're talking directly to the kernel, then stick to linux/*.  do not mix 
the two.

> Unfortunately, doing so gets me:
> 
> In file included from src/NetworkInterface.cpp:1032:
> /usr/include/linux/if.h:139: error: redefinition of ‘struct ifmap’
> /usr/include/net/if.h:113: error: previous definition of ‘struct ifmap’
> /usr/include/linux/if.h:175: error: redefinition of ‘struct ifreq’
> /usr/include/net/if.h:128: error: previous definition of ‘struct ifreq’
> /usr/include/linux/if.h:225: error: redefinition of ‘struct ifconf’
> /usr/include/net/if.h:178: error: previous definition of ‘struct ifconf’
> 
> 
> I need <net/if.h> for the if_indextoname() stuff, but I need <linux/if.h>
> for the correct IFF_* flags (some of which are also defined in
> <net/if.h>).

please post a patch to add any new/missing flags to net/if.h that are not yet 
there.

> Better yet, is there a simpler solution to this issue?

convince the kernel people to not export the same struct names as the C 
library.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20120811/3fc42784/attachment.sig>


More information about the Libc-alpha mailing list