c++ - 为什么linux中有多个fcntl.h?

标签 c++ c linux gcc header-files

我写了一个包含 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/

相关文章:

linux - 关于 Linux 上 CUDA C 的程序 "Hello world"

c++ - 一个负整数与一个更大的无符号整数相加是否提升为无符号整数?

c++ - C++ 中随机生成的 vector 不会改变值

c++ - Win32 在代码中更改菜单

c - Unix下最快的删除目录

c - 关于双指针和三指针/双维数组

java - linux - 无法查看从 java 创建的目录

java - Apache Commons Email 安装在 Eclipse : cannot be resolved

c++ - 如何在 C++ 中使用类修改器将变量加倍

c - 使用具有不同路径名的 Makefile 构建 Linux 内核模块