我正在尝试编译这段代码:
std::string myString(...)
if (myString == __MY_MACRO__) { ... }
在我的蚂蚁剧本中,我有:
<property unless:set="myprop" name="myprop" value="foo" />
...
<compilerarg value='-D__MY_MACRO__="${myprop}"' />
它在Linux上编译但在Windows上没有编译,我得到以下错误:
[cc] <command-line>:0:27: error: 'foo' was not declared in this scope
[cc] XXX.cpp:X:Y: note: in expansion of macro '__MY_MACRO__'
[cc] if (myString == __MY_MACRO__) {
我也试过
<compilerarg value="-D__MY_MACRO__="${myprop}"" />
但结果相同。
谢谢!
答案 0 :(得分:0)
找到解决方案:
<compilerarg value='-D__MY_MACRO__="\"${myprop}"\"' />