预处理器指令

作者在 2014-01-30 09:46:22 发布以下内容

1.#define指令定义了一个标识符及一个字符序列(即字符集合)。在源程序中每次遇到该标识符时,就用定义的字符序列替换它。标识符被称为宏名,替换过程称为宏替换,指令的一般形式为:

            #define  macro-name  char-sequence

2.#error指令强迫编译器停止编译,它主要用于程序调试。#error指令的一般形式为:

           #error   error-message

3.#if, #else, #elif, #endif

           #if   expression

           #elif  expression1

           #endif

4.#undef指令取消其后那个前面已定义过的宏名,也就是不定义宏。#undef指令的一般形式为:

           #undef  macro-name

5.#line

#include <stdio.h>
#line 100                              
//reset the line counter
int main()                      
{                                           //line 100
printf("%d\n", __LINE__);    //line 101
return 0;                               //line 102
}

C++参考大全 | 阅读 1350 次
文章评论,共0条
游客请输入验证码