我在某个地方读到过这样的话
#define X defined(Y)
之前是无效的,但现在似乎可以工作。
这里有一个例子:
#define WIN_PLAT defined(_WIN32)
#if WIN_PLAT
# undef WIN_PLAT
# define WIN_PLAT 1
#else
# undef WIN_PLAT
# define WIN_PLAT 0
#endif
#if defined(_WIN32)
。不要因为想耍聪明而搞砸了。 - undefined#if _WIN32
//#define WIN_PLAT 1
//#else
//#define WIN_PLAT 0
这段代码有什么问题? - undefineddefined
是由宏展开产生的(这就是你正在做的事情),那么程序的行为是未定义的。未定义行为不需要被诊断,程序表现出的任何行为都是允许的。因此,“似乎工作正常”和“在蓝月期间停止工作”都是标准下同样正确的行为。 - undefined