Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

#ifdef WIN32 #elif WIN64 #endif

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?

like image 927
Felix Dombek Avatar asked Aug 22 '14 16:08

Felix Dombek


1 Answers

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.

like image 172
The name's Bob. MS Bob. Avatar answered Jan 02 '23 17:01

The name's Bob. MS Bob.