#ifdef #if defined() 区别

2019-02-14  本文已影响0人  我的随笔

#ifdef  只能用于一个条件判断

 #if defined() 可以用于多个条件判断

例子:

#if defined(WIN32) && !defined(UNIX)/* Do windows stuff */

#elif defined(UNIX) && !defined(WIN32)/* Do linux stuff */

#else/* Error, both can't be defined or undefined same time */

#endif

The difference between the two is that #ifdef can only use a single condition,

while #if defined(NAME) can do compound conditionals.

ref: https://stackoverflow.com/questions/1714245/difference-between-if-definedwin32-and-ifdefwin32

上一篇下一篇

猜你喜欢

热点阅读