当前位置: 首页 > 工具软件 > andLinux > 使用案例 >

<linux/in.h> VS <netinet/in.h>

萧奇
2023-12-01

The linux/*.h headers were really meant for internal kernel use and if Linux were being created today, these files would not even exist under /usr/include. But early on, a lot of the userspace libc (libc4 and libc5 at the time) relied on Linux headers to define types, constants, structures, etc. for use in userspace, so netinet/in.h contained just #include <linux/in.h> or similar, and the lovely tradition got started. Today the only headers in the linux tree that should be used for userspace apps are some things related to supporting specific hardware at a low level, like the Linux console, framebuffer, video4linux, etc.

In short, you should use netinet/in.h (the standard header specified by POSIX) and pretend you never saw linux/in.h. :-)


 类似资料: