The "not", "and", etc... are keywords in C++ (macros in C). Is there any way to "enable" them in Visual Studio 2013? I'm able to use the words as macroses with iso646.h
included. But VS seems not be able to recognize them as keywords.
Using /Za
seems to enable them without including iso646.h
, see it live, the following program produces an error without using /Za
but works fine otherwise:
int main()
{
int x = 1, y = 0 ;
if (x and y)
{
//...
}
return 0;
}
As ta.speot.is indicates /Za disables extensions, the following documentation indicates you must include ios646.h
otherwise:
Under /Ze, you have to include iso646.h if you want to use text forms of the following operators:
and it lists the alternative tokens below.
Note, I knew I saw this before, I include a link to a bug report for this in my answer to a similar question. Although this does not include the workaround noted above.
Note 2: Cheers and hth. - Alf indicates that there may be many undesirable consequences to turning off extension and therefore you may be better off just including iso646.h
.
Use a forced include (option /FI
) of the iso646.h
header.
For work in the command interpreter you can put this in your CL
environment variable, or e.g. in a response file.
Turning off Visual C++ language extensions with /Za
can also do the trick, at the cost of rendering the compiler pretty much useless – since Microsoft code such as the Windows API headers generally uses the extensions.
On a more recent version of VS (tested on Version 15.7.0 Preview 3.0); ensure that conformance mode is set for visual studio:
It then compiles with the alternative operator representations.
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