发现什么海合会包括路径 [英] Finding out what the GCC include path is
问题描述
我试图找到编程Linux上的的#include
路径,按照我的理解,在实践中意味着寻找什么GCC认为它是。 (那是千真万确?如何锵办呢?)
I'm trying to programmatically find the #include
path on Linux, which as I understand it, in practice means finding what GCC considers it to be. (Is that quite true? How does Clang do it?)
据<一个href=\"http://gcc.gnu.org/onlinedocs/cpp/Search-Path.html\">http://gcc.gnu.org/onlinedocs/cpp/Search-Path.html一些部件涉及CPU架构和GCC的版本;尤其是后者似乎棘手的;我想这可以通过运行来获得的gcc --version
和解析输出(或的gcc -v
),但这似乎充其量不雅和脆弱的在最坏的情况。从一个人的code假设一个人的程序中做它正在使用GCC编译可能是另一种选择,但它需要根据这个假设。
According to http://gcc.gnu.org/onlinedocs/cpp/Search-Path.html some of the components involve the CPU architecture and the GCC version; the latter in particular seems tricky; I suppose it could be obtained by running gcc --version
and parsing the output (or gcc -v
), but this seems inelegant at best and fragile at worst. Doing it from within one's code assuming one's program is being compiled with GCC might be another option, but it would require depending on that assumption.
什么是推荐的方式做到这一点?
What's the recommended way to do it?
推荐答案
命令
echo | cpp -Wp,-v
将显示包括在使用路径。
will show the include path in use.
这篇关于发现什么海合会包括路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!