防止gcc搜索当前目录“-I-”选项包括搜索路径 [英] prevent gcc from searching the current dir "-I-" option on include search path

查看:506
本文介绍了防止gcc搜索当前目录“-I-”选项包括搜索路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的开发环境大量使用了具有本地修改的头文件的目录,编译器而不是提交的存储库版本。

Our dev environment makes heavy use of directories with locally modified headers that should be seen by the compiler instead of the "committed" "repository" versions.

A包括头文件B,gcc在同一目录A中查找B,并且不遵守seach路径。
所以我们使用gcc上的 -I - 选项来阻止。 Gcc将严格遵循include-path的层次结构。
与gcc4一样, -I - 选项已弃用,并由 -iqoute 重新定义。
我不知道如何使用 -iquote 选项获得相同的行为,因为我认为它缺乏禁用搜索的副作用current目录。

If header A includes header B, gcc looks for B in the same directory A was in and does not obey the seach path. So we used the -I- option on gcc to prevent that. Gcc will strictly follow the hierarchy of the include-path then. As with gcc4 the -I- option is deprecated and repaced by -iqoute. I can't figure out how to get the same behaviour with the -iquote option because I think it is lacking the side-effect of disabling the search in the "current" directory.

请参阅 http://gcc.gnu.org/onlinedocs/cpp/Invocation.html#Invocation

任何想法如何实现相同的行为? / p>

Any ideas how to achieve the same behaviour?

推荐答案

AFAIK,没有其他方法来停用你抱怨的行为,除了使用 #include< foo.h> 而不是 #includefoo.h

AFAIK, there is no other way to desactivate the behaviour you are complaining about other than using the form #include <foo.h> instead of #include "foo.h" in your code.

ISTR,但是我没有找到参考,不提供另一种机制的原因是: -I - 使用 #includefoo.h的形式确保它们获得自己的内部头文件 foo.h 和使用 -I - 在某些情况下破坏了它们,如果别人碰巧在搜索路径上有类似名称的文件。

ISTR, but I've failed to find a reference, that the rationale for deprecating -I- without providing another mechanism for that aspect is that libraries commonly use the form #include "foo.h" to ensure they get their own internal header file foo.h and the use of -I- broke them in some cases if someone else happened to have a file similarly named earlier on the search path.

这篇关于防止gcc搜索当前目录“-I-”选项包括搜索路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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