找出 GCC 包含的路径是什么 [英] Finding out what the GCC include path is

查看:29
本文介绍了找出 GCC 包含的路径是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试以编程方式在 Linux 上找到 #include 路径,据我所知,这实际上意味着找到 GCC 认为它是什么.(这是真的吗?Clang 是怎么做到的?)

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?)

根据http://gcc.gnu.org/onlinedocs/cpp/Search-Path.html 部分组件涉及CPU架构和GCC版本;尤其是后者似乎很棘手;我想它可以通过运行 gcc --version 并解析输出(或 gcc -v)来获得,但这在最好的情况下似乎不优雅,在最坏的情况下显得很脆弱.假设一个人的程序是用 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.

推荐的方法是什么?

推荐答案

命令

echo | gcc -E -Wp,-v -

将显示正在使用的包含路径.

will show the include path in use.

这篇关于找出 GCC 包含的路径是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆