预处理指令

// The include directive instructs the preprocessor to paste the text of the given file into the current file.
// 粘贴指定文件的内容
#include
// 定义宏PI
#define PI 3.1415926
// 取消定义PI
#undef PI

条件编译(Conditional Compilation)

// 检查xxx是否已被定义为宏,如果是,则到#endif为止的内容都包含进来
#ifdef xxx
 ...
#endif
// 检查xxx是否没有被宏定义
// One common use of '#ifndef' is to include code only the first time a header file is included.
#ifndef xxx
 ...
#endif
// 如果condition为true,则includes the code until the closing #endif.
// 如果不是true,则不包含
#if condition
 ...
#endif
The '#endif' directive closes off the following directives: #if, #ifdef, or #ifndef.
In other words, '#endif' always matches the nearest '#ifdef' (or '#ifndef', or '#if').

endif
ifdef

你可能感兴趣的:(C/C++,C语言)