#ifdef WIN32 #elif WIN64 #endif

半世苍凉 提交于 2020-01-03 10:58:17

问题


I have come across some example code that goes like this:

#ifdef WIN32
   ...
#elif WIN64
   ...
#endif

In an #ifdef block, is it actually legal to use #elif to mean #elif defined?


回答1:


No, it shouldn't be. That's not to say that some obscure C compiler wouldn't accept it as such, but it isn't part of the C standard.

Normally, for something like this you would use either #elifdef FOO (which I've never actually seen in production code) or #elif defined(FOO) (like you mentioned).

This code appears to be working in a odd way; it's rather first checking if WIN32 is defined, then checking if WIN64 is nonzero.



来源:https://stackoverflow.com/questions/25451376/ifdef-win32-elif-win64-endif

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!