【发布时间】:2021-05-31 12:37:50
【问题描述】:
我想要一个有条件的打印宏,我可以根据是否定义了宏来打开或关闭它,例如#define DEBUG。我的第一个想法是:
#define DEBUG_PRINT(...) #ifdef DEBUG printf(__VA_ARGS__) #endif
但这并不完全有效,我在尝试时收到以下错误:
pc.c:16:24: error: '#' is not followed by a macro parameter
#define DEBUG_PRINT(...) #ifdef DEBUG printf(__VA_ARGS__) #endif
什么是定义类似DEBUG_PRINT 宏的有效方法,该宏在打开布尔值时打印?
【问题讨论】:
标签: c