[英]C++ define macro /D with output of a shell command WINDOWS
I am trying to define a macro that gets the output of a shell command, just like in Linux when using gcc and passing arguments like: 我正在尝试定义一个获取shell命令输出的宏,就像在Linux中使用gcc并传递如下参数一样:
gcc ... -DSEED=$(date +%s)
This is what I tried just for testing purposes: 这是我仅出于测试目的而尝试的方法:
/DTEST=$(echo 5)
Is it even possible to do something like this in vs2017 ? 在vs2017中甚至可以做这样的事情吗?
Yes/No/Maybe/I don't know. 是/否/也许/我不知道。
int main() { return RET; }
is a valid program compiled with 是使用编译的有效程序
/DRET=0
Now you need to invoke your compiler in a way such that 0
is replaced by whatever value you want, but this is well outside the scope of C++. 现在,您需要以某种方式调用编译器,以将
0
替换为所需的任何值,但这超出了C ++的范围。
What about bash for windows + CMake? Windows + CMake的bash呢?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.