#if的使用
if 后面接的是表达式
#if a==1
code
……
#endif
如果#if后面的表达式能成立,就会把#if和#endif之间的代码编译进去
#if defined的使用
#if defined (x)
code
……
如果x这个宏又被定义过,则把#if和#endif之间的代码编译进去
注意点
- 两个都只是用来决定某段代码是否被编译
- 记得加#endif
#if a==1
code
……
#endif
如果#if后面的表达式能成立,就会把#if和#endif之间的代码编译进去
#if defined (x)
code
……
如果x这个宏又被定义过,则把#if和#endif之间的代码编译进去