编译预处理(277KB).pptVIP

  • 1
  • 0
  • 约2.83千字
  • 约 8页
  • 2018-04-01 发布于未知
  • 举报
第七章 编译预处理 作用:对源程序编译之前做一些处理,生成扩展C源程序 种类 宏定义 #define 文件包含 #include 条件编译 #if--#else--#endif等 格式: “#”开头 占单独书写行 语句尾不加分号 如 if(x==YES) printf(“correct!\n”); else if (x==NO) printf(“error!\n”); 展开后: if(x==1) printf(“correct!\n”); else if (x==0) printf(“error!\n”); 7.1 宏定义 不带参数宏定义 一般形式: #define 宏名 [宏体] 功能:用指定标识符(宏名)代替字符序列(宏体) 宏展开:预编译时,用宏体替换宏名---不作语法检查 如 #define YES 1 #define NO 0 #define PI 3.1415926 #define OUT printf(“Hello,World”); 宏体可缺省,表示宏名 定

文档评论(0)

1亿VIP精品文档

相关文档