Have following code which is working under Linux but gives error for MSVS
#if (false)
....
#endif
The error is: fatal error C1017: invalid integer constant expression
I found this report on Microsoft's web: http://msdn.microsoft.com/en-us/library/h5sh3k99.aspx
While the info described there differs a little bit compared to my case as I didn't use the "#define"
So my question is:
It looks like your version of MS compiler does not support false as a built-in constant. This is not surprising, because Microsoft has a spotty record of supporting standards for C and C++.
One way to make this work without changing the code is to pass command-line parameters to the compiler to define false as 0 and true as 1:
-Dfalse=0 -Dtrue=1
Is there any way to make it working for MSVC without changing code ?
Not really. Defining a macro for false
is forbidden by the standard for good reasons, [macro.names]/2:
A translation unit shall not
#define
or#undef
names lexically identical to keywords, to the identifiers listed in Table 3, or to the attribute-tokens described in 7.6.
And I don't see any other way.
If the code must be updated, what's the best solution for this kind of case?
Substitute 0
for false
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With