python – 在SCons中创建混合(值集)CPPDEFINES

我想将编译器定义设置为-DBLUB以及-DFOO = 1.

目前我只有:

env.Append("CPPDEFInes",["BLUB","VALUE2"])

我现在想通过“FOO”包含第三个定义:1然后使用CPPDEFInes作为字典,以便稍后我可以很容易地测试

env["CPPDEFInes"].get("FOO") == 1

或者.我尝试的一切都会导致语法错误或奇怪的错误.
能解释一下奇怪的方法在python中对我这么做吗?

最佳答案
如果需要为任何单个定义指定值,则CPPDEFInes必须是字典.

scons User Manual

If $CPPDEFInes is a dictionary,the values of the $CPPDEFPREFIX and $CPPDEFSUFFIX construction variables will be appended to the beginning and end of each item from the dictionary. The key of each dictionary item is a name being defined to the dictionary item’s corresponding value; if the value is None,then the name is defined without an explicit value.

对于你的例子,我建议:

env.Append(CPPDEFInes = { 'BLUB': None,'VALUE2': None,'Foo': 1 })

要么

env.Append(CPPDEFInes = { 'BLUB': None,'VALUE2': None })
...and sometime later...
env.Append(CPPDEFInes = { 'Foo': 1 })

相关文章

在前一篇博客中我们介绍了加侧旋的乒乓球弧圈技术的模拟,本...
在近期conda的版本更新中,有可能会删除路径下的_sysconfigd...
本文主要展示了一些lambda表达式的使用示例,通过这些示例,...
本文通过对比Jax和Numpy计算Normalized Hamming Distance的过...
我们知道GPU加速在可并行化程度比较高的算法中,能够发挥出比...
Numpy这个库在Python编程中非常的常用,不仅在性能上补足了P...