预处理器
来自cppreference.com
< cpp
![]() |
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
预处理器在编译开始之前运行。预处理的结果是单个的文件,它之后会传递给实际的编译器。
[编辑] 指令
预处理指令控制着预处理器的行为。每个指令占用一行,并具有以下的格式:
-
#
字符 - 预处理指令(
define
、undef
、include
、if
、ifdef
、ifndef
、else
、elif
、endif
、line
、error
、warning
、pragma
之一) - 参数(取决于指令)
- 换行符
空指令(#
后跟一个换行符)是允许的,它没有效果。
[编辑] 功能
预编译器有翻译源文件的功能:
- 有条件地编译源文件的若干部分(由指令
#if
、#ifdef
、#ifndef
、#else
、#elif
和#endif
控制)。 - 替换文本宏,而可能是串联或引用标识符(由指令
#define
和#undef
,符号#
和##
控制)Original:replace text macros while possibly concatenating or quoting identifiers (controlled by directives#define
and#undef
, and operators#
and##
)The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - 包含其他文件(由指令
#include
控制) - 产生一个警告(由指令
#warning
控制) - 产生一个错误(由指令
#error
控制)
的预处理器可以控制以下几个方面:
Original:
The following aspects of the preprocessor can be controlled:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.