我想编写一个宏,根据其参数的布尔值吐出代码.所以说DEF_CONST(true)应该扩展到const,并且DEF_CONST(false)应该扩展为无.
DEF_CONST(true)
const
DEF_CONST(false)
显然,以下方法不起作用,因为我们不能在#defines中使用另一个预处理器:
#define DEF_CONST(b_const) \ #if (b_const) \ const \ #endif
c c-preprocessor
c ×1
c-preprocessor ×1