Is it possible to turn off support for “and” / “or” boolean operator usage in gcc?

后端 未结 4 2046
忘了有多久
忘了有多久 2020-12-11 06:15

GCC seems to allow \"and\" / \"or\" to be used instead of \"&&\" / \"||\" in C++ code; however, as I expected, many compilers (notably MSVC 7) do not support this. T

4条回答
  •  心在旅途
    2020-12-11 07:05

    They are part of the C++ standard, see for instance this StackOverflow answer (which quotes the relevant parts of the standard).

    Another answer in the same question mentions how to do the opposite: make them work in MSVC.

    To disable them in GCC, use -fno-operator-names. Note that, by doing so, you are in fact switching to a non-standard dialect of C++, and there is a risk that you end up writing code which might not compile correctly on standard-compliant compilers (for instance, if you declare a variable with a name that would normally be reserved).

提交回复
热议问题