简体   繁体   English

包括哪个unistd.h? (C ++)

[英]Which unistd.h is being included? (c++)

I was exploring the libraries for educational purposes and came across the file os_defines.h , which on my MacBoook is located in usr/include/c++/4.2.1/bits . 我正在出于教育目的浏览这些库,并遇到了文件os_defines.h,该文件位于MacBoook上的usr / include / c ++ / 4.2.1 / bits中。 There I find #include <unistd.h> , so I did a quick finder search for that file and came up with no less than 7 files of that name! 我在其中找到#include <unistd.h> ,因此我快速查找了该文件,并找到了不少于7个该名称的文件! The files are not copies, and NONE of them are located in the same folder as os_defines.h - so which file exactly is being included? 这些文件不是副本,并且没有一个与os_defines.h位于同一文件夹中-那么究竟要包含哪个文件?

I get the feeling I'm missing something obvious, but I am a wee rookie, and if anyone can shine me a light it would be greatly appreciated. 我感觉到我缺少明显的东西,但是我是个新手,如果有人可以给我照亮,我将不胜感激。

Well, we cannot mark duplicates across SE sites (and I couldn't find one quickly at Stack Overflow), and assuming you are using GCC I'll restate the answer here: 好吧,我们不能在SE网站上标记重复项(而且我在Stack Overflow上找不到快速),并且假设您使用的是GCC,我将在此处重申答案

The preprocessor can tell you what it uses 预处理器可以告诉您使用什么

cpp -x c++ -v cpp -x c ++ -v

... ...

  #include "..." search starts here: #include <...> search starts here: /usr/include/c++/4.4 /usr/include/c++/4.4/i486-linux-gnu /usr/include/c++/4.4/backward /usr/local/include /usr/lib/gcc/i486-linux-gnu/4.4.1/include /usr/lib/gcc/i486-linux-gnu/4.4.1/include-fixed /usr/include/i486-linux-gnu /usr/include End of search list. 

You can add directories to the search path by setting the C_INCLUDE_PATH and/or CPLUS_INCLUDE_PATH environment variiables 您可以通过设置C_INCLUDE_PATH和/或CPLUS_INCLUDE_PATH环境变量将目录添加到搜索路径

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM