2012-08-14 55 views
44

我正在尝试编写一个构建脚本 - 并且想要确定包含是否包含系统。所以我希望g ++告诉我它使用的包含路径。转储包含来自g ++的路径

cpp -v似乎是最明显的最佳镜头,但它并没有给我C++路径。

所以,我想:

g++ -Xpreprocessor -v 

不工作很正确 - G ++捕获-v为它自己的详细输出。

感谢, 奥利弗

回答

66

乔纳森Wakely一个更好的选择(适用于铛太):

g++ -E -x c++ - -v < /dev/null 
clang++ -E -x c++ - -v < /dev/null 

我注意到有指定语言CPP的标志。这像一个魅力。

cpp -xc++ -v < /dev/null 


#include "..." search starts here: 
#include <...> search starts here: 
/usr/local/Cellar/gcc/4.7.0/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.0/../../../../include/c++/4.7.0 
/usr/local/Cellar/gcc/4.7.0/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.0/../../../../include/c++/4.7.0/x86_64-apple-darwin11.4.0 
/usr/local/Cellar/gcc/4.7.0/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.0/../../../../include/c++/4.7.0/backward 
/usr/local/Cellar/gcc/4.7.0/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.0/include 
/usr/local/include 
/usr/local/Cellar/gcc/4.7.0/gcc/include 
/usr/local/Cellar/gcc/4.7.0/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.0/include-fixed 
/usr/include 
/System/Library/Frameworks 
/Library/Frameworks 
End of search list. 

只注意到它是海湾合作委员会的-x c++ to be -xc++重要4.2

+7

或等价,'G ++ -E -x C++ - -v 2012-08-14 08:31:45

+0

Cheers - 这是一个更好的选择。在叮当中工作。 – Oliver 2012-08-14 23:20:54

+0

可以简化为'g ++ -E -x C++ -v/dev/null'。 – Rufflewind 2017-03-17 19:41:00