包含路径中具有相同名称的两个标头 [英] Two header with same name in include path
问题描述
在我的make文件的CINCLUDE路径中,有两个具有相同名称的标头.
In CINCLUDE path in my make file there are two headers with same name.
我无法删除其中一个.如何指示makefile优先处理特定文件夹中的头文件.
I cannot remove one of them . How can I instruct makefile to give priority to header files in a specific folder.
推荐答案
通常由编译器指定.例如,对于gcc,您可以创建以下文件:
This is usually something specified by the compiler. For example with gcc, you can create the following files:
qq.c:
#include <qq.h>
int main (void) {
return 0;
}
1/qq.h:
#error file number 1
2/qq.h:
#error file number 2
然后,当您编译它们时:
Then, when you compile them:
pax> gcc -I1 -I2 -o qq qq.c
In file included from qq.c:1:
1/qq.h:1:2: #error file number 1
pax> gcc -I2 -I1 -o qq qq.c
In file included from qq.c:1:
2/qq.h:1:2: #error file number 2
换句话说,指定包含路径(用-I
)的顺序决定了搜索的顺序(还有其他事情,例如标头是否与系统标头命名相同,但不必担心)我们在这里).
In other words, it's the order in which the include paths are specified (with -I
) which dictates the order of search (there are other things such as whether headers are named the same as system headers but they need not concern us here).
这篇关于包含路径中具有相同名称的两个标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!