我們要檢查a是否定義
#if defined a
#undef a
#define a 200
#endif
上述語句檢驗a是否被定義,如果被定義,則用#undef語句解除定義,並重新定義a為200
#ifndef a //如果a沒有被定義
#define a 100
#endif
#undef為解除定義
#ifndef是if not defined的縮寫,即如果沒有定義
作用
1 條件編譯
#if !defined XXX_XXX
#define XXX_XXX
#endif
2 錯誤信息
#if !defined(__cplusplus)
#error C++ compiler required.
#endif