gpt4 book ai didi

c++ - Scons 没有指定 CPPPATH,仍然可以检测到 .h 依赖吗?

转载 作者:行者123 更新时间:2023-11-30 03:34:54 24 4
gpt4 key购买 nike

例如,我有一个名为 1.h 的头文件:

#define MY 3

然后我有一个名为 myc 的子目录以及 1.c 和 f.c 文件:

$ cat 1.c
void f();
int main()
{
return 0;
}
$ cat f.c
#include"../1.h"
#include<stdio.h>
void f(){printf("hello %d\n",MY);}

$ cat SConscript
Program('my2files',['1.c','f.c'])

运行scons,OK。然后我把1.h改成了

    #define MY 2

我没有在我的 SConstruct 中指定 CPPPATH=../,所以我希望 scons 可以检测到这种依赖关系。我再次运行 scons,好吧,似乎检测到了这个变化,.c 文件又被编译了。

我的问题是,CPPPATH 是否隐式无用? scons 还是 gcc 可以检测到头文件的变化?

最佳答案

根据 SCons 文档,它似乎仅由 SCons 自动添加

Like the $LIBPATH variable, the $CPPPATH variable may be a list of directories, or a string separated by the system-specific path separation character (':' on POSIX/Linux, ';' on Windows). Either way, SCons creates the right command-line options so that the following example:

Program('hello.c', CPPPATH = ['include', '/home/project/inc'])

斯康斯 CPPPATH DOC

关于c++ - Scons 没有指定 CPPPATH,仍然可以检测到 .h 依赖吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41659009/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com