【发布时间】:2014-11-21 12:21:34
【问题描述】:
我有一些代码具有以下形式的现有预处理器条件指令:
#ifndef SYMBOL_XYZ
// some code here
#else
// some other code here
#endif
我想添加一个取代该逻辑的新条件,我认为这是这样做的方法,但我不确定 C 预处理器中嵌套和优先级的微妙之处。
#ifdef NEW_SYMBOL_ABC
// some new code here that takes precedence over the other two conditions
#else
#ifndef SYMBOL_XYZ
// some code here
#else
// some other code here
#endif
#endif
我有这个权利吗?是否相当于这样做:
#ifndef NEW_SYMBOL_ABC
#ifndef SYMBOL_XYZ
// some code here
#else
// some other code here
#endif
#else
// some new code here that takes precedence over the other two conditions
#endif
【问题讨论】:
-
称为预处理器
-
没关系。如果你查看gcc头文件,你会发现很多这样的预处理器嵌套。
标签: c c-preprocessor