【发布时间】:2010-09-24 15:05:40
【问题描述】:
在我的 make 文件的 CINCLUDE 路径中,有两个同名的标题。
我无法删除其中之一。如何指示 makefile 优先考虑特定文件夹中的头文件。
【问题讨论】:
标签: makefile
在我的 make 文件的 CINCLUDE 路径中,有两个同名的标题。
我无法删除其中之一。如何指示 makefile 优先考虑特定文件夹中的头文件。
【问题讨论】:
标签: makefile
这通常是由编译器指定的。例如使用 gcc,您可以创建以下文件:
qq.c:
#include <qq.h>
int main (void) {
return 0;
}
1/qq.h:
#error file number 1
2/qq.h:
#error file number 2
然后,当你编译它们时:
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)决定了搜索的顺序(还有其他一些事情,例如标头是否与系统标头命名相同,但它们不需要关注我们在这里)。
【讨论】: