【发布时间】:2011-01-21 13:24:07
【问题描述】:
我想知道#ifdef、#ifndef 和#endif 的用法以及在哪种情况下必须使用这些条件句,它们有什么用? #ifdef 和 #ifndef 有什么区别?
例如:
#define MY_Global
#ifdef MY_Global
// write some code (Inside the method)
#endif
或者,
#ifdef MY_Global
-(void) customMethod
{
// Do something
}
#endif
哪一个是正确的,它应该只写在方法内部还是在方法外部工作?我以前没用过这个。所以请解释一下?
谢谢!
【问题讨论】:
-
第二个意味着如果
MY_Global没有被定义,customMethod将完全丢失
标签: iphone preprocessor using-directives