首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

条件预处理有关问题

2013-03-22 
条件预处理问题linux下写的,用GCC调试出了问题,求各位大神给个解释#include stdio.h#define Max(x, y) (

条件预处理问题
linux下写的,用GCC调试出了问题,求各位大神给个解释条件预处理有关问题


#include <stdio.h>

#define Max(x, y) (x > y ? x:y)
int main(void)
{
int c = 0;
#if c==0  //如果换成 #if c 输出结果就没有,这个不应该是判断是否定义变量c的吗??求解判断是否定义变量c的表达式
printf("%d\n ", Max(2, 4));
#endif
return 0;
}
linux c
[解决办法]

#include <stdio.h>
 
#define Max(x, y) (x > y ? x:y)
int main(void)
{
#ifndef DEF_C
#define DEF_C
    int c = 0; //把c的定义用保护宏保护起来
#endif

#ifdef DEF_C
printf("%d\n ", Max(2, 4));
#endif
    return 0;
}


热点排行