linux c 宏判断多条件 #ifdef 和 #if defined 的区别

多个条件判断用 #if defined   

单个条件判断用 #ifdef

#ifdef 和 #if defined 的区别在于,后者可以组成复杂的预编译条件,比如

#if defined (AAA) && defined (BBB)
xxxxxxxxx
#endif

#if defined (AAA) || VERSION > 12
xxxxxxxxx
#endif

而#ifdef 就不能用上面的用法,也就是说,当你要判断单个宏是否定义时
#ifdef 和 #if defined 效果是一样的,但是当你要判断复杂的条件时,只能用 #if

猜你喜欢

转载自blog.csdn.net/whatday/article/details/102691372