Where are include files stored - Ubuntu Linux, GCC

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

So, when we do the following:

#include 

versus

#include \"myFile.h\"

the compiler, GCC in

4条回答
  •  醉梦人生
    2020-12-02 09:03

    See here: Search Path

    Summary:

    #include 
    

    When the include file is in brackets the preprocessor first searches in paths specified via the -I flag. Then it searches the standard include paths (see the above link, and use the -v flag to test on your system).

    #include "myFile.h"
    

    When the include file is in quotes the preprocessor first searches in the current directory, then paths specified by -iquote, then -I paths, then the standard paths.

    -nostdinc can be used to prevent the preprocessor from searching the standard paths at all.

    Environment variables can also be used to add search paths.

    When compiling if you use the -v flag you can see the search paths used.

提交回复
热议问题