2013年8月8日 星期四

ios objective c #ifdef #endif #define #if 用法

1.情況


#define _xxx


#ifdef _xxx

程序1

#else

程序2

#endif

這表示 如果 _xxx 的字符 是否有被 #define 定義過 如果定義了就會跑入程序1(如上所示)


2.情況


#define _xxx


#ifndef _xxx

程序1

#else

程序2

#endif

这里使用了#ifndef,表示的是if not def

跟上面相反  如果 如上面會跑 程序2


3.情況


#if 常量

程序1

#else

程序2

 #endif

這裡表示 常量 為真的  (非0 隨便的數字只要不是0) ,就執行程序1






0 意見:

張貼留言