我刚看到这个线程,描述了如何添加条件宏: Conditional value for a #define条件宏的#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
有任何解决方法,以帮助摆脱警告?
UPDATE:
所以,我想包括我的定义中的条件:
#define doSomething(){\
#if TARGET_IPHONE_SIMULATOR
\\ do something
#else
\\ do something else
#endif
}\
而是抛出一个错误:
error: '#' is not followed by a macro parameter.
你忘了doSomething是一个已定义的宏。如果我有#define doSomething()#if ...这将打破宏,你会得到错误:'#'后面没有宏参数。 – Bach 2011-02-15 23:57:48