From Bugzilla Helper: User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.6) Gecko/20050323 Firefox/1.0.2 Fedora/1.0.2-1 Description of problem: Try to compile the following example: $ cat foo.c #include <sys/socket.h> #include <netpacket/packet.h> #include <net/ethernet.h> #include <sys/ioctl.h> #include <net/if.h> int foo(char *ifr_name) { return(0); } This is what I get: $ gcc -c foo.c foo.c:7: error: syntax error before '.' token For some reason cpp expands ifr_name: $ cpp foo.c | tail extern void if_freenameindex (struct if_nameindex *__ptr) __attribute__ ((__nothrow__)); # 6 "foo.c" 2 int foo(char *ifr_ifrn.ifrn_name) { return(0); } Version-Release number of selected component (if applicable): gcc-4.0.0-0.37 How reproducible: Always Steps to Reproduce: See description Additional info:
Did some more digging. The bad include is: /usr/include/net/if.h Tried compiling the following and got same error: $ cat foo.c #include <net/if.h> int foo(char *ifr_name) { return(0); } This include belongs to: $ rpm -q -f /usr/include/net/if.h glibc-headers-2.3.4-16
Maybe this isn't a bug because I see a lot of namespace pollution in this include file. I thought that if the names were not documented then they would start with an underscore(â_â). From the include: # define ifr_name ifr_ifrn.ifrn_name /* interface name */ # define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */ # define ifr_addr ifr_ifru.ifru_addr /* address */ # define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-p lnk */ # define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */ # define ifr_netmask ifr_ifru.ifru_netmask /* interface net mask */ # define ifr_flags ifr_ifru.ifru_flags /* flags */ # define ifr_metric ifr_ifru.ifru_ivalue /* metric */ # define ifr_mtu ifr_ifru.ifru_mtu /* mtu */ # define ifr_map ifr_ifru.ifru_map /* device map */ # define ifr_slave ifr_ifru.ifru_slave /* slave device */ # define ifr_data ifr_ifru.ifru_data /* for use by interface */ # define ifr_ifindex ifr_ifru.ifru_ivalue /* interface index */ # define ifr_bandwidth ifr_ifru.ifru_ivalue /* link bandwidth */ # define ifr_qlen ifr_ifru.ifru_ivalue /* queue length */ # define ifr_newname ifr_ifru.ifru_newname /* New name */ Are these documented anywhere in the man pages?
Well, you are compiling without feature macros, so you can't talk about namespace pollution. The default namespace is not covered by standards, so as you reported it, there is really not a bug. ifr_* is not reserved namespace for net/if.h just on Linux, but e.g. Solaris too. With -D_XOPEN_SOURCE=600, I agree there is a bug though, http://www.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_02.html doesn't include ifr_* for net/if.h and http://www.opengroup.org/onlinepubs/009695399/basedefs/net/if.h.html doesn't speficy these. So I wonder if #ifdef __USE_MISC in net/if.h shouldn't be changed to at least: #if defined __USE_MISC && (!defined __USE_XOPEN2K || defined __USE_GNU) or something like that. Solaris guards these with #if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) but given that net/if.h header was not covered in Unix98, I think the above should be enough.
I shouldn't respond this early, the header is ok. __USE_MISC is not defined for -D_XOPEN_SOURCE=600. So there is no bug.
Sorry for being an idiot, but why don't these reserved names show up in the man page for "if.h" or in: http://www.gnu.org/software/libc/manual/html_node/Reserved-Names.html http://www.gnu.org/software/libc/manual/html_node/Interface-Naming.html Is there any place to check the reserved namespaces for Linux and the libc includes? I've googled around without success.