Why does VS not define the alternative tokens for logical operators?

You ask about the rationale. Here’s one possible reason, not necessarily the one that most influenced the Visual C++ team:

  1. Those are valid identifiers in C.
  2. Microsoft’s recommendation has long been to use C++ mode for both C and C++ code, rather than maintaining a modern C compiler.
  3. Valid C code using these as identifiers would gratuitously break if they were compiled as keywords.
  4. People trying to write portable C++ are mostly using /permissive- or /Za for maximum conformance anyway, which will cause these to be treated as keywords.
  5. The workaround to treat them as keywords in /Ze by including a header file is easy and portable. (G++’s workaround -fno-operator-names isn’t bad either, but putting the option in the source code rather than the build system is somewhat nicer.)

Leave a Comment