·条件编译指令:#if、#elif、#else 和 #endif,用于按条件跳过源代码中的节
·声明指令:#define 和 #undef,分别用于定义和取消定义条件编译符号
·诊断指令:#error 和 #warning,分别用于发出错误和警告
·区域指令:#region 和 #endregion,用于显式标记源代码中的节
·行指令:#line,用于控制行号
说明:声明指令必须位于源文件中所有实代码的前面,否则将发生编译时错误。
示例:
#define AAA
#undef BBB
#region 判断条件编译符号是否定义
#if AAA
#warning AAA is defined
#else
#error AAA is not defined
#endif
#if !BBB
#error BBB is not defined
#else
#warning BBB is defined
#endif
#endregion
评论(0)
暂无评论。