如何停止C中的预编译?
查看config.h中的代码:如何停止C中的预编译?,c,precompiled,conditional-compilation,C,Precompiled,Conditional Compilation,查看config.h中的代码: #if (API_TYPE == 1) #define URL_API @"https://dapi.xxx.com/1.1/" #elif (API_TYPE == 2) #define URL_API @"https://tapi.xxx.com/1.1/" #elif (API_TYPE == 3) #define URL_API @"https://api.xxx.com/1.1/" #else // I want stop
#if (API_TYPE == 1)
#define URL_API @"https://dapi.xxx.com/1.1/"
#elif (API_TYPE == 2)
#define URL_API @"https://tapi.xxx.com/1.1/"
#elif (API_TYPE == 3)
#define URL_API @"https://api.xxx.com/1.1/"
#else
// I want stop pre-compile if in here.
// assert(0);
#endif
API_类型只能定义为1,2,3。如果定义为其他值,则是错误的。
我可以在#else路径中编写一些非法代码。但它并不完美。如果预编译过程转到#else路径,是否有任何命令或方法停止预编译过程?您可以插入#error“error message”
,这将停止预处理,编译甚至不会开始。使用#error