2
我有具有如下形式的一个现有的预处理条件指令一些代码:下预处理器条件指令优先级和嵌套
#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
它被称为预处理器 – 2014-11-21 04:15:24
看起来很适合我。 – JS1 2014-11-21 04:18:55
没关系。 如果你检查gcc头文件,你会发现很多像这样的预处理器嵌套。 – sunny1304 2014-11-21 04:20:45