gee*_*aur 34
它是一个预处理程序指令(例如),当您期望-D定义几个可能的符号之一,但没有一个.
#if defined(BUILD_TYPE_NORMAL)
# define DEBUG(x) do {;} while (0) /* paranoid-style null code */
#elif defined(BUILD_TYPE_DEBUG)
# define DEBUG(x) _debug_trace x /* e.g. DEBUG((_debug_trace args)) */
#else
# error "Please specify build type in the Makefile"
#endif
Run Code Online (Sandbox Code Playgroud)
当预处理器命中#error指令时,它会将字符串报告为错误消息并停止编译; 错误消息的确切内容取决于编译器.
小智 13
我可能有无效的代码,但它的东西像......
#if defined USING_SQLITE && defined USING_MYSQL
#error You cannot use both sqlite and mysql at the same time
#endif
#if !(defined USING_SQLITE && defined USING_MYSQL)
#error You must use either sqlite or mysql
#endif
#ifdef USING_SQLITE
//...
#endif
#ifdef USING_MYSQL
//...
#endif
Run Code Online (Sandbox Code Playgroud)