Alternative markers (none, etc.) In VisualStudio 2013

"Not", "and" etc. are keywords in C ++ (macros in C). Is there a way to β€œenable” them in Visual Studio 2013? I can use words as macros with iso646.h enabled. But VS, it seems, cannot recognize them as keywords.

+4
c ++ visual-studio-2013
source share
3 answers

Using /Za seems to allow them without including iso646.h , to see it live , the following program throws an error without using /Za but it works fine:

 int main() { int x = 1, y = 0 ; if (x and y) { //... } return 0; } 

As ta.speot.is points out, / Za disables extensions, you must enable ios646.h otherwise:

In the / Ze section, you need to enable iso646.h if you want to use text forms of the following operators:

and it lists alternative tokens below.

Notice, I knew that I saw this before, I include a link to the error report for this in my answer to a similar question. Although this does not apply to the workaround noted above.

Note 2: Cheers and hth. - Alf indicates that there can be many undesirable consequences for disabling the extension, and therefore you might be better off including iso646.h .

+6
source share

Use force include (option /FI ) in the iso646.h header.

To work in the shell, you can put this in your CL environment variable or, for example, in the answer file.


Disabling Visual C ++ language extensions using /Za can also do the trick by rendering the compiler to a large extent, since Microsoft code, such as the Windows API headers, usually uses extensions.

+3
source share

In a later version of VS (verified in version 15.7.0 Preview 3.0); make sure that visual studio is set to compliance mode: enter image description here

Then it compiles with alternative representations of the operator .

+1
source share

All Articles