跳至內容

C 程式設計/預處理器參考

來自華夏公益教科書

預處理器參考

[編輯 | 編輯原始碼]

存在以下預處理器語句

Statement Subsequent items on the control line Meaning
========= ==================================== =======
#if       conditional-expression               conditional
#ifdef    identifier                           true iff identifier is a macro
#ifndef   identifier                           true iff identifier is not a macro
#elif     conditional-expression               continues a conditional
#else                                          continues a conditional
#endif                                         ends a conditional
#include  header-name                          includes a file
#define   identifier                           defines a macro
#undef    identifier                           removes a previously defined macro
#line     number filename                      changes the line number and file name
#error    token-list                           specifies an error
#pragma   token-list                           catchall

一些非標準編譯器也指定#warning#import.

上面的條件表示式可以包含定義運算子。

上面的#define 識別符號後面可以跟可選的引數列表,然後是可選的替換標記列表。引數列表的左括號必須沒有前導空格。

華夏公益教科書