Reputation: 4706
I am currently porting some code from Visual studio to mingw and apparently the following code seems to work in Visual Studio but fails in Mingw
#if defined(BATCH_TRIANGLESTRIP)
static const size_t VERT_COUNT = 4;
#elif defined(BATCH_TRIANGLELIST)
static const size_t VERT_COUNT = 6;
#elif //error here on mingw
#error BATCH_TRIANGLESTRIP or BATCH_TRIANGLELIST need to be defined
#endif
My question is with the last #elif
I looked over at the documentation of msdn and apparently they dont have a #elif
statement without a condition. I wanted to know will the equivalent of above code in mingw be
#if defined(BATCH_TRIANGLESTRIP)
static const size_t VERT_COUNT = 4;
#elif defined(BATCH_TRIANGLELIST)
static const size_t VERT_COUNT = 6;
#else
#error BATCH_TRIANGLESTRIP or BATCH_TRIANGLELIST need to be defined
#endif
This is the error I get with the original code
error: #elif with no expression
Upvotes: 0
Views: 395
Reputation: 263257
#elif
requires a constant expression according to the C++ standard (and the C standard as well). The failure to diagnose a bare #elif
is a bug in Visual Studio.
The equivalent in standard C++ would use #else
rather than #elif
. Both Visual Studio and MinGW should handle that correctly -- as should any conforming compiler.
Upvotes: 1