c++条件编译指令问题
来源:百度知道 编辑:UC知道 时间:2024/06/23 02:04:19
#include<stdio.h>
#define PI 3.1415
#define BEGIN {
#define END }
main()
BEGIN
int i=100;
#if 5
printf("i=%d\n",i);
#endif
#ifdef PI
printf("ifdif PI=%f\n",PI);
#endif
#ifndef PI
printf("ifndef PI=%f\n",PI);
#endif
#elif 1
printf("elif PI=%f",PI);
#else
printf("elif2 PI=%f",PI);
#endif
END
提示错误: fatal error C1018: unexpected #elif请大家帮帮忙
#elif 常数表达式
语句部分1
#else
语句部分2
#endif
若常数表达式为非0,执行语句部分1;否则执行语句部分2
#define PI 3.1415
#define BEGIN {
#define END }
main()
BEGIN
int i=100;
#if 5
printf("i=%d\n",i);
#endif
#ifdef PI
printf("ifdif PI=%f\n",PI);
#endif
#ifndef PI
printf("ifndef PI=%f\n",PI);
#endif
#elif 1
printf("elif PI=%f",PI);
#else
printf("elif2 PI=%f",PI);
#endif
END
提示错误: fatal error C1018: unexpected #elif请大家帮帮忙
#elif 常数表达式
语句部分1
#else
语句部分2
#endif
若常数表达式为非0,执行语句部分1;否则执行语句部分2
这就跟你没写if就写else一个道理啊。 上面 的各种if和endif已经配对了, 下面直接来个 elif 当然出错
#elif 1
这是什么??
#elif 1
c++里面没有#elif这东西
把#elif 1前一句#endif去掉