宏中的宏

twe*_*ypi 11 c++ macros c-preprocessor

可以在宏的c ++中放一个宏吗?

就像是:

#define Something\
#ifdef SomethingElse\ //do stuff \
#endif\
Run Code Online (Sandbox Code Playgroud)

我尝试过它没有用,所以我的猜测它不起作用,除非有某种语法可以解决它?

Mic*_*zek 16

宏,是的.预处理器指令,这是你发布的,没有


Ale*_*lli 11

不,但你可以简单地通过拉出#ifdef作为顶层来重构它,并使用两个不同的#define Something ...版本来实现真假分支#ifdef.