有没有预处理指令可以检查一个常量是否未定义。我知道#ifndef
指令,但我也在寻找一个#elif not defined
指令。是否存在#elif not defined
指令?
这是我如何使用它:
#define REGISTER_CUSTOM_CALLBACK_FUNCTION(callbackFunctName) \
#ifndef CUSTOM_CALLBACK_1 \
#define CUSTOM_CALLBACK_1 \
FORWARD_DECLARE_CALLBACK_FUNCTION(callbackFunctName) \
#elif not defined CUSTOM_CALLBACK_2 \
#define CUSTOM_CALLBACK_2 \
FORWARD_DECLARE_CALLBACK_FUNCTION(callbackFunctName) \
#elif not not defined CUSTOM_CALLBACK_3 \
#define CUSTOM_CALLBACK_3 \
FORWARD_DECLARE_CALLBACK_FUNCTION(callbackFunctName) \
#endif
#elif not not defined CUSTOM_CALLBACK_3
不是未定义吗? - JustMaximumPower#define
或#if
或#elif
成为宏的一部分。你的宏必须重新设计,以确保它没有内部“分支”。所有宏分支都必须在“外部”完成。它不能被“嵌入”到一个宏中。 - AnT stands with Russia