1. 程式人生 > >工具:探測gcc預設include目錄

工具:探測gcc預設include目錄

$ gcc -v -x c -E /dev/null
Using built-in specs.
[...]
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/x86_64-linux-gnu/4.8/include
 /usr/local/include
 /usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.
[...]

The GCC flags in order of specification:

參    數 說明
-v Enable verbose mode. In the preprocessor’s case, print the final form of the include path, among other things.
-x c Tells GCC that the input is to be treated as C source code. To find the G++ include path, substitute -x c++. You should be able to do the same for all the other languages supported by your GCC installation, assuming those languages support the concept of preprocessing.
-E Stop after preprocessing (it’s an empty source file, after all).