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