我写了一个包含 fcntl.h
的 c 程序文件。我搜索文件并得到如下结果:
[xunyl@localhost csapp]$ find /usr/include/ -name "fcntl.h"
/usr/include/asm/fcntl.h
/usr/include/asm-generic/fcntl.h
/usr/include/linux/fcntl.h
/usr/include/sys/fcntl.h
/usr/include/bits/fcntl.h
/usr/include/fcntl.h
[xunyl@localhost csapp]$ grep -rn "O_RDONLY" /usr/include/
/usr/include/asm-generic/fcntl.h:19:#define O_RDONLY 00000000
/usr/include/linux/cdrom.h:32: * - drive = open("/dev/cdrom", O_RDONLY);
/usr/include/linux/cdrom.h:33: * + drive = open("/dev/cdrom", O_RDONLY | O_NONBLOCK);
...
我发现 gcc 调用 /usr/include/asm-generic/fcntl.h
实际上当我把#include <fcntl.h>
在程序中。我只是想知道 gcc 如何确定应该调用哪个“fcntl.h”。是否有任何调用顺序或优先级?
最佳答案
一个包含另一个,另一个包含下一个,直到包含定义的那个。
关于c++ - 为什么linux中有多个fcntl.h?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36418639/