Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
158 views
in Technique[技术] by (71.8m points)

c++ - Alternative tokens (not, and, etc...) in VisualStudio 2013

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...