C语言条件编译用途:
1.判断宏是否被定义;
2.判断宏是否未被定义;
3.选择性执行
#include <stdio.h>
#define DEBUG 10
#define HIGH 2
int main() {
int value = 10;
//1.用于判断宏是否被定义
#ifdef DEBUG
printf("1.DEBUG defined\r\n");
#else
printf("1.DEBUG not defined\r\n");
#endif
//2.判断宏是否未被定义
#ifndef DEBUG
prinf("2.DEBUG not defined\r\n");
#else
printf("2.DEBUG defined\r\n");
#endif
//3.选择性执行代码
#if DEBUG==10
printf("xiangdeng\r\n");
#elif DEBUG>10
printf("dayu10\r\n");
#else
printf("xiaoyu10\r\n");
#endif
#if HIGH
printf("success\r\n");
#else
printf("not success\r\n");
#endif
}