#ifdef WIN32 #elif WIN64 #endif

I came across some sample code that looks like this:

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

In the #ifdef block, is #ifdef really right to use #elif to mean #elif defined ?

+6
source share
1 answer

No, this should not be. This does not mean that some obscure C compiler did not accept it as such, but it is not part of the C standard.

Typically, for something like this, you would use #elifdef FOO (which I have never seen in production code) or #elif defined(FOO) (as you mentioned).

This code works in an odd way; rather, it first checks to see if WIN32 defined, and then checks to see if WIN64 nonzero.

+9
source

Source: https://habr.com/ru/post/974223/


All Articles