3

I found that there are linux/ip.h and netinet/ip.h in /usr/include, and some of them are the same. Why are there duplicate files here with different names, what's the difference between them?

1 Answer 1

2

History.

Back in the Early Days, before computers roamed the earth, two completely independent groups of people started development on two separate software subsystems.

Taking advantage of the privileges of developers, each group picked lovely names for the parts of their subsystems. "ip.h" is such a name.

When the time came to merge their subsystems, both groups wanted to keep their lovely names.

By putting the copy of ip.h the subsystem needs in a subdirectory makes it easy for developers. One wanting to use the definitions in netinet's version of ip.h need only #include <netinet/ip.h>, while a developer wanting to compile with the linux version does #include <linux/ip.h>.

1
  • @shengfuzou you can do a diff on them to see if they are complete the same .. diff /usr/include/linux/ip.h /usr/include/netinet/ip.h
    – Soren A
    Feb 24, 2017 at 14:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .