redefinition of 'struct iphdr' - netinet/ip.h vs linux/ip.h

Chris Packham Chris.Packham@alliedtelesis.co.nz
Mon Feb 10 22:37:00 GMT 2020


Hi,

I have an application that wants to include both netinet/ip.h and
linux/if_tunnel.h.

As of kernel headers versions newer than v4.8 the application fails to
compile with the following error

  make[1]: Entering directory 'compile-test'
    CC       compile-test.o
  In file included from /usr/include/linux/if_tunnel.h:7,
                   from compile-test.c:3:
  /usr/include/linux/ip.h:86:8: error: redefinition of 'struct iphdr'
   struct iphdr {
        ^~~~~
  In file included from compile-test.c:2:
  /usr/include/netinet/ip.h:44:8: note: originally defined here
   struct iphdr
          ^~~~~
  make[1]: *** [Makefile:385: compile-test.o] Error 1

Looking at the linux commit commit 1fe8e0f074c7
("include/uapi/linux/if_tunnel.h: include linux/if.h, linux/ip.h and
linux/in6.h") I can see that the application was probably working by
luck.

Doing a bit of searching I can see various fixes with removing one of
the offending header files but this causes more problems for the
application in question.

Is there a way of making netinet/ip.h and linux/if_tunnel.h co-exist?

Thanks,
Chris Packham


More information about the Libc-help mailing list