Where are include files stored - Ubuntu Linux, GCC

后端 未结 4 1435
面向向阳花
面向向阳花 2020-12-02 08:35

So, when we do the following:

#include 

versus

#include \"myFile.h\"

the compiler, GCC in

4条回答
  •  日久生厌
    2020-12-02 08:59

    gcc is a rich and complex "orchestrating" program that calls many other programs to perform its duties. For the specific purpose of seeing where #include "goo" and #include will search on your system, I recommend:

    $ touch a.c
    $ gcc -v -E a.c
     ...
    #include "..." search starts here:
    #include <...> search starts here:
     /usr/local/include
     /usr/lib/gcc/i686-apple-darwin9/4.0.1/include
     /usr/include
     /System/Library/Frameworks (framework directory)
     /Library/Frameworks (framework directory)
    End of search list.
    # 1 "a.c"
    

    This is one way to see the search lists for included files, including (if any) directories into which #include "..." will look but #include <...> won't. This specific list I'm showing is actually on Mac OS X (aka Darwin) but the commands I recommend will show you the search lists (as well as interesting configuration details that I've replaced with ... here;-) on any system on which gcc runs properly.

提交回复
热议问题