操纵包含文件的搜索路径 [英] Manipulating the search path for include files
问题描述
我的开发环境是这样的,我有 some_header.h
在 / usr / include目录
和 /其它/目录
。 /其它/目录
包含我需要在我的计划,包括一些头文件,但我想用 some_header.h
从 / usr / include目录
。当我使用
My development environment is such that I have some_header.h
in /usr/include
and in /another/directory
. /another/directory
contains some header files I need to include in my program, but I want to use some_header.h
from /usr/include
. When I use
gcc ... -I/another/directory
GCC使用 /another/directory/some_header.h
。如果我用
gcc ... -I/usr/include -I/another/directory
GCC做同样的事情,因为它忽略 / usr / include目录
,因为它是标准的搜索路径的一部分,但是它得到后非标准的目录搜索包括 -I
gcc does the same thing because it ignores /usr/include
since it is part of the standard search path, but it gets searched after non standard directories included with -I.
任何想法?
推荐答案
你有没有看 -nostdinc
?
手册上说:
不要搜索头文件的标准系统目录。
只有目录用-I选项中指定(和
当前文件的目录,如果合适的话)进行搜索。
-nostdinc
Do not search the standard system directories for header files. Only the directories you have specified with -I options (and the directory of the current file, if appropriate) are searched.
当然,这是指的您的必须指定任何正常的推移,你的标准的搜索路径上做的希望...
Of course that means that you will have to specify anything that normally goes on the standard search path that you do want...
这篇关于操纵包含文件的搜索路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!