我有这个 SConstruct 文件:
env=Environment()
env.Append(CCFLAGS = ['-std=c99', '-Wall', '-Wextra', '-g'])
print env["CCFLAGS"]
#Program('test_array.c',CCFLAGS=['-std=c99', '-Wall', '-Wextra', '-g'],
CPPPATH = '.', LIBS='stuff', LIBPATH=".")
#Program('test_array.c',CPPPATH = '.', LIBS='stuff', LIBPATH=".")
取消注释第一个 Program() 的输出是:
scons
scons: Reading SConscript files ...
-std=c99 -Wall -Wextra -g
scons: done reading SConscript files.
scons: Building targets ...
gcc -o test_array.o -c -std=c99 -Wall -Wextra -g -I. test_array.c
gcc -o test_array test_array.o -L. -lstuff
scons: done building targets.
取消注释第二个 Program() 的输出是:
scons
scons: Reading SConscript files ...
-std=c99 -Wall -Wextra -g
scons: done reading SConscript files.
scons: Building targets ...
gcc -o test_array.o -c -I. test_array.c
test_array.c: In function 'test_insert':
test_array.c:85:4: error: 'for' loop initial declarations are only allowed in C99 mode
test_array.c:85:4: note: use option -std=c99 or -std=gnu99 to compile your code
env 变量具有 CCFLAGS 的值,但我不知道为什么在 Program() 调用中未明确指定时不使用它。