预处理器

来自cppreference.com
< cpp
 
 
C + +语言
大会的主题
Original:
General topics
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
预处理器
评论
关键字
流量控制
Original:
Flow control
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
条件执行语句
Original:
Conditional execution statements
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
迭代语句
Original:
Iteration statements
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
跳转语句
Original:
Jump statements
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
功能
Original:
Functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
函数声明
lambda函数的声明
函数模板
的历史。内嵌说明
异常规范 (过时了)
noexcept说明 (C++11)
例外
Original:
Exceptions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
命名空间
Original:
Namespaces
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
类型
Original:
Types
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
decltype specifier (C++11)
规范
Original:
Specifiers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
CV符
存储时间说明符
constexpr说明 (C++11)
汽车符 (C++11)
alignas说明 (C++11)
初始化
Original:
Initialization
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Original:
Literals
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
布尔文字
nullptr (C++11)
用户定义的 (C++11)
表达式
Original:
Expressions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
另一种表示形式
实用工具
Original:
Utilities
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
类型
Original:
Types
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
typedef declaration
声明类型别名 (C++11)
属性 (C++11)
施放
Original:
Casts
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
隐式转换
const_cast conversion
static_cast conversion
dynamic_cast conversion
reinterpret_cast conversion
C-风格和功能转换
内存分配
Original:
Memory allocation
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Original:
Classes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
类特定的功能特性
Original:
Class-specific function properties
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
虚函数
覆盖说明 (C++11)
最后说明 (C++11)
明确的 (C++11)
静态的
特殊的成员函数
Original:
Special member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
模板
Original:
Templates
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
类模板
函数模板
模板特化
参数包 (C++11)
杂项
Original:
Miscellaneous
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
内联汇编
 
 

预处理器在编译开始之前运行。预处理的结果是单个的文件,它之后会传递给实际的编译器。

[编辑] 指令

预处理指令控制着预处理器的行为。每个指令占用一行,并具有以下的格式:

  • #字符
  • 预处理指令(defineundefincludeififdefifndefelseelifendiflineerrorwarningpragma 之一)
  • 参数(取决于指令)
  • 换行符

空指令(#后跟一个换行符)是允许的,它没有效果。

[编辑] 功能

预编译器有翻译源文件的功能:

  • 有条件地编译源文件的若干部分(由指令 #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.