转储包含来自 g++ 的路径 [英] Dump include paths from g++
问题描述
我正在尝试编写一个小构建脚本,并想确定包含是否为系统包含.所以我希望 g++ 告诉我它正在使用的包含路径.
I'm trying to write a little build script, and want to determine if the includes are system includes or not. So I want g++ to tell me the include path's it's using.
cpp -v
显然是最好的选择,但它没有给我 C++ 路径.
cpp -v
seems the obvious best shot, but it doesn't give me the C++ paths.
所以我尝试了:
g++ -Xpreprocessor -v
这不太正确 - g++ 捕获 -v
以作为它自己的详细输出.
Which doesn't work quite right - g++ captures the -v
for it's own verbose output.
推荐答案
来自 Jonathan Wakely 的一个更好的选择(也适用于 clang):
From Jonathan Wakely a better option (works on clang too):
g++ -E -x c++ - -v < /dev/null
clang++ -E -x c++ - -v < /dev/null
我注意到 cpp 中有一个用于指定语言的标志.这就像一个魅力.
I noticed there's a flag in cpp for specifying language. This works like a charm.
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.
刚刚注意到在 gcc 4.2 上 -x c++ 是 -xc++
很重要
Just noticed that it is important for the -x c++ to be -xc++
on gcc 4.2
这篇关于转储包含来自 g++ 的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!