加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

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

发布时间:2020-12-16 22:17:18 所属栏目:Python 来源:网络整理
导读:我想将编译器定义设置为-DBLUB以及-DFOO = 1. 目前我只有: env.Append("CPPDEFINES",["BLUB","VALUE2"]) 我现在想通过“FOO”包含第三个定义:1然后使用CPPDEFINES作为字典,以便稍后我可以很容易地测试 env["CPPDEFINES"].get("FOO") == 1 或者.我尝试的一

我想将编译器定义设置为-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 })

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读