#define _CRT_NO_SECURE_WARNING
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define max2(a,b) (a)>(b)? (a):(b)
#define max3(a,b,c) (a)> (max2(b,c))?(a):(max2(b,c))
#define D1
int main()
{ //条件编译一共三种
#ifdef D1//1.条件编译(预处理做的)2. 如果是#ifndef 就是测试不存在 3.#if
printf("D1\n");
#else
printf("other\n");
#endif
//
#ifndef _D2_H_ //_D2_H_ 自定义宏,每个头文件的宏不一样
#define _D 2_H_
#else
printf("other\n");
#endif
//
# if 1
printf("TEST");
#else
printf("NO");
#endif
printf("%d\n",max2(1,2));
printf("%d\n", max3(1, 2,3));
system("pause");
}
宏定义(用宏定义写一个求最大值)和条件编译
猜你喜欢
转载自blog.csdn.net/qq_23859701/article/details/80385492
今日推荐
周排行