【发布时间】:2011-02-02 00:09:35
【问题描述】:
我刚刚看到这个帖子,描述了如何添加条件宏: Conditional value for a #define
但就我而言,我是在条件内定义一个函数。
#if TARGET_IPHONE_SIMULATOR
#define doSomething(){\
\\ does something
}\
#else
#define doSomething(){\
\\ does something else
}\
#endif
这确实有效,但我导致 gcc 编译器抛出此警告:
"doSomething" redefined
This is the location of the previous arguments
是否有任何解决方法可以帮助消除警告?
更新:
所以我尝试在我的定义中包含条件:
#define doSomething(){\
#if TARGET_IPHONE_SIMULATOR
\\ do something
#else
\\ do something else
#endif
}\
但这会引发错误:
error: '#' is not followed by a macro parameter.
【问题讨论】:
标签: gcc macros c-preprocessor