【问题标题】:Two header with same name in include path包含路径中具有相同名称的两个标头
【发布时间】:2010-09-24 15:05:40
【问题描述】:

在我的 make 文件的 CINCLUDE 路径中,有两个同名的标题。

我无法删除其中之一。如何指示 makefile 优先考虑特定文件夹中的头文件。

【问题讨论】:

    标签: makefile


    【解决方案1】:

    这通常是由编译器指定的。例如使用 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)决定了搜索的顺序(还有其他一些事情,例如标头是否与系统标头命名相同,但它们不需要关注我们在这里)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-06-29
      • 2021-06-22
      • 2013-02-16
      • 2018-12-21
      • 2019-03-19
      • 2016-11-30
      • 2017-08-25
      相关资源
      最近更新 更多