This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Linux issues with <net/if.h> and <linux/if.h>
- From: Philip Prindeville <philipp_subx at redfish-solutions dot com>
- To: libc-alpha at sources dot redhat dot com
- Date: Fri, 10 Aug 2012 14:40:43 -0600
- Subject: Linux issues with <net/if.h> and <linux/if.h>
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.
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>).
I thought if I compiled with "-D_POSIX_SOURCE -ansi" then "__USE_MISC" would not be turned on, and this would work, but that hasn't been the case (or it's getting turned on anyway and I can't figure out why).
I'm using:
glibc-devel-2.12-1.80.el6_3.3.x86_64
glibc-common-2.12-1.80.el6_3.3.x86_64
kernel-2.6.32-220.el6.x86_64
kernel-devel-2.6.32-220.17.1.el6.x86_64
gcc-c++-4.4.6-4.el6.x86_64
gcc-4.4.6-4.el6.x86_64
glibc-headers-2.12-1.80.el6_3.3.x86_64
Some web searches list some workarounds, etc. but none of them see applicable.
Is there a foolproof way to get __USE_MISC turned off?
Better yet, is there a simpler solution to this issue?
Thanks,
-Philip