| 預處理器
|
| #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; |
|