[英]Using a macro in another macro and then undefining(#undef) the first macro c++
[英]Using/Copying the value of a macro variable in/to a macro function before undefining it: is it possible?
如果我有:
#define A 1
#define B() A
#undef A
这段代码:
#if B()
std::cout << "B" << std::endl;
#else
std::cout << "not B" << std::endl;
#endif
将打印“不是B”。 有没有一种方法可以将A分配给另一个宏变量/函数,然后清除掉A?
背景:在cmake的configure_file上下文中使用它 ,其中A
是使用#cmakedefine01
定义的。
没有。
宏不是类,也不具有这种复杂性。
如果一个宏是用另一个宏定义的,则两个宏都必须保留下来才能使替换正常工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.