Bug 3937

Summary: Macro and struct redefinition in <netinet/in.h> and <linux/in.h>
Product: uClibc Reporter: wuyun1984_1984
Component: OtherAssignee: unassigned
Status: RESOLVED INVALID    
Severity: normal CC: uclibc-cvs
Priority: P5    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: Linux   
Host: Target:
Build:

Description wuyun1984_1984 2011-07-01 10:04:28 UTC
When <netinet/in.h> and <linux/in.h> are simultaneously included in your code, a screen of compiling errors jumped out:

/usr/include/linux/in.h:26: error: redeclaration of enumerator ‘IPPROTO_IP’
/usr/include/netinet/in.h:33: error: previous definition of ‘IPPROTO_IP’ was here
/usr/include/linux/in.h:27: error: redeclaration of enumerator ‘IPPROTO_ICMP’
/usr/include/netinet/in.h:37: error: previous definition of ‘IPPROTO_ICMP’ was here
/usr/include/linux/in.h:28: error: redeclaration of enumerator ‘IPPROTO_IGMP’
/usr/include/netinet/in.h:39: error: previous definition of ‘IPPROTO_IGMP’ was here
/usr/include/linux/in.h:29: error: redeclaration of enumerator ‘IPPROTO_IPIP’
/usr/include/netinet/in.h:41: error: previous definition of ‘IPPROTO_IPIP’ was here
/usr/include/linux/in.h:30: error: redeclaration of enumerator ‘IPPROTO_TCP’
/usr/include/netinet/in.h:43: error: previous definition of ‘IPPROTO_TCP’ was here
/usr/include/linux/in.h:31: error: redeclaration of enumerator ‘IPPROTO_EGP’
/usr/include/netinet/in.h:45: error: previous definition of ‘IPPROTO_EGP’ was here
/usr/include/linux/in.h:32: error: redeclaration of enumerator ‘IPPROTO_PUP’
/usr/include/netinet/in.h:47: error: previous definition of ‘IPPROTO_PUP’ was here
/usr/include/linux/in.h:33: error: redeclaration of enumerator ‘IPPROTO_UDP’
/usr/include/netinet/in.h:49: error: previous definition of ‘IPPROTO_UDP’ was here
/usr/include/linux/in.h:34: error: redeclaration of enumerator ‘IPPROTO_IDP’
/usr/include/netinet/in.h:51: error: previous definition of ‘IPPROTO_IDP’ was here
/usr/include/linux/in.h:36: error: redeclaration of enumerator ‘IPPROTO_RSVP’
/usr/include/netinet/in.h:61: error: previous definition of ‘IPPROTO_RSVP’ was here
/usr/include/linux/in.h:37: error: redeclaration of enumerator ‘IPPROTO_GRE’
/usr/include/netinet/in.h:63: error: previous definition of ‘IPPROTO_GRE’ was here
/usr/include/linux/in.h:39: error: redeclaration of enumerator ‘IPPROTO_IPV6’
/usr/include/netinet/in.h:55: error: previous definition of ‘IPPROTO_IPV6’ was here
/usr/include/linux/in.h:41: error: redeclaration of enumerator ‘IPPROTO_ESP’
/usr/include/netinet/in.h:65: error: previous definition of ‘IPPROTO_ESP’ was here
/usr/include/linux/in.h:42: error: redeclaration of enumerator ‘IPPROTO_AH’
/usr/include/netinet/in.h:67: error: previous definition of ‘IPPROTO_AH’ was here
/usr/include/linux/in.h:43: error: redeclaration of enumerator ‘IPPROTO_PIM’
/usr/include/netinet/in.h:79: error: previous definition of ‘IPPROTO_PIM’ was here
/usr/include/linux/in.h:45: error: redeclaration of enumerator ‘IPPROTO_COMP’
/usr/include/netinet/in.h:81: error: previous definition of ‘IPPROTO_COMP’ was here
/usr/include/linux/in.h:46: error: redeclaration of enumerator ‘IPPROTO_SCTP’
/usr/include/netinet/in.h:83: error: previous definition of ‘IPPROTO_SCTP’ was here
/usr/include/linux/in.h:48: error: redeclaration of enumerator ‘IPPROTO_RAW’
/usr/include/netinet/in.h:85: error: previous definition of ‘IPPROTO_RAW’ was here
/usr/include/linux/in.h:50: error: redeclaration of enumerator ‘IPPROTO_MAX’
/usr/include/netinet/in.h:88: error: previous definition of ‘IPPROTO_MAX’ was here
/usr/include/linux/in.h:54: error: redefinition of ‘struct in_addr’
/usr/include/linux/in.h:113: error: redefinition of ‘struct ip_mreq’
/usr/include/linux/in.h:119: error: redefinition of ‘struct ip_mreqn’
/usr/include/linux/in.h:125: error: redefinition of ‘struct ip_mreq_source’
/usr/include/linux/in.h:131: error: redefinition of ‘struct ip_msfilter’
/usr/include/linux/in.h:144: error: redefinition of ‘struct group_req’
/usr/include/linux/in.h:150: error: redefinition of ‘struct group_source_req’
/usr/include/linux/in.h:157: error: redefinition of ‘struct group_filter’
/usr/include/linux/in.h:170: error: redefinition of ‘struct in_pktinfo’
/usr/include/linux/in.h:178: error: redefinition of ‘struct sockaddr_in’
make: *** [test.o] Error 1


I think <netinet/in.h> should be originated from <linux/in.h>, but what <linux/in.h> says is just opposite:

 * Authors:	Original taken from the GNU Project <netinet/in.h> file.
 *		Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>

Is that mean I can never change the structs defined in netinet/in.h?
That is quit ridiculous.
The right logic is you can change the definition of them, but you should re-compile the kernel and the application simultaneously.
Comment 1 Mike Frysinger 2011-07-12 03:37:47 UTC
pick an interface and stick with it: the C library or the Linux kernel.  mixing the two isnt supported.