简体   繁体   中英

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 . 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! 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?

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:

The preprocessor can tell you what it uses

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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