美文网首页
#ifdef #if defined() 区别

#ifdef #if defined() 区别

作者: 我的随笔 | 来源:发表于2019-02-14 14:42 被阅读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

相关文章

网友评论

      本文标题:#ifdef #if defined() 区别

      本文链接:https://www.haomeiwen.com/subject/ybseeqtx.html