1

In answers to The written versions of the logical operators, it is indicated that the keywords and, or, and not are, in fact, keywords that are defined as part of the C++ language (but without specifically stating C++11).

In Visual Studio 2013, I am attempting to build pre-existing code (known to build on Linux) which uses the or keyword (if (A_ or B_) {...}, where A_ and B_ are properly defined), and the following compiler error is generated:

error C2065: 'or' : undeclared identifier

From Microsoft's (apparently) official list of C++ keywords for Visual Studio 2013, or is not listed.

I would like confirmation that the and, or, and not keywords are not supported in Visual Studio 2013.

(The alternative is that I am missing either an #include file, or a required compiler setting.)

Community
  • 1
  • 1
Dan Nissenbaum
  • 13,558
  • 21
  • 105
  • 181
  • You need to include a header IIRC in MSVC2013 (== nonstandard) `iso646.h`, [and_eq @ MSDN](http://msdn.microsoft.com/en-us/library/1s7s448s.aspx) – dyp Jun 11 '14 at 18:58
  • Probably a duplicate question. Try disabling language extensions: http://stackoverflow.com/a/555524/420683 – dyp Jun 11 '14 at 19:02
  • A bit of history: They've been introduced because `&` and `!` etc were fancy characters back then, not supported or forbidden for certain architectures, or even reused for localized characters in a 7-bit pseudo-ASCII character set. A more readable alternative to trigraphs (source: D&E, pp.159-160) – dyp Jun 11 '14 at 19:10
  • Be aware that if you do disable language extensions using `/Za` then there's a good chance you won't be able to include most (probably all) of the Windows API headers. – Praetorian Jun 11 '14 at 19:15
  • @dyp: Yes, but alternative tokens don't entirely replace trigraphs, since they're not replaced in string and character literals. – Keith Thompson Jun 11 '14 at 19:15

0 Answers0