| 预处理器
|
| #include <stdio.h> |
包含 stdio.h 的内容 |
| #error text |
显示 text 作为编译时错误 |
| #warning text |
显示 text 作为编译时警告 |
| #pragma |
编译器特定选项 |
| #define M |
定义 M |
| #undef M |
取消定义 M |
| #if (condition) |
条件编译 |
| #ifdef M |
如果 M 已定义则编译 |
| #ifndef M |
如果 M 未定义则编译 |
| #elif (condition) |
条件编译 |
| #else |
条件编译 |
| #endif |
结束条件部分 |
| defined() |
宏是否已定义。 |
| !defined() |
宏是否未定义 |
| M ## D |
将 M 和 D 合并为 MD |
| #M |
将 M 视为字符串 "M" |
|
| 语法
|
| if (bool expr) block [else block] |
| for ([expr];[condition];[expr]) block |
| while (condition) block |
| do { } while (condition) |
| type identifier([type identifier, ...]); |
| type identifier([type identifier, ...]) { } |
| class identifier [:[private|public] type, ...]; |
| class identifier [:[private|public] type, ...] { [private:] }; |
| struct identifier [:[public|private] type, ...]; |
| struct identifier [:[public|private] type, ...] { [public:] }; |
| union identifier; |
| union identifier { type identifier; ... }; |
| enum identifier; |
| enum identifier { identifier [=int_value], ... }'; |
| typedef type identifier; |
|