问题描述
我刚刚从 Reddit 上读到了这篇不错的文章.
I've just read this nice piece from Reddit.
他们提到 and
和 or
是 &&
和 ||
They mention and
and or
being "Alternative Tokens" to &&
and ||
直到现在我才真正意识到这些.当然,每个人都知道二图和三图,但是和
和 或
?从何时起?这是标准的最新补充吗?
I was really unaware of these until now. Of course, everybody knows about the di-graphs and tri-graphs, but and
and or
? Since when? Is this a recent addition to the standard?
我刚刚使用 Visual C++ 2008 对其进行了检查,它似乎除了语法错误之外没有将这些识别为任何其他内容.怎么回事?
I've just checked it with Visual C++ 2008 and it doesn't seem to recognize these as anything other than a syntax error. What's going on?
推荐答案
MSVC 仅在您使用 /Za
选项禁用扩展时才支持它们作为关键字;至少在 VC7.1 (VS2003) 中确实如此.
MSVC supports them as keywords only if you use the /Za
option to disable extensions; this is true from at least VC7.1 (VS2003).
您可以通过包含 iso646.h
将它们支持为宏.
You can get them supported as macros by including iso646.h
.
我的猜测是,他们认为默认使用关键字会破坏太多现有代码(如果他们是对的,我不会感到惊讶).
My guess is they believe that making them keywords by default would break too much existing code (and I wouldn't be surprised if they are right).
几周前在 SO 某处的某个问题中讨论了这一点,但我无法通过 SO 的搜索或 Google 找到该死的东西.
This was discussed in a question a couple weeks ago somewhere here on SO, but I can't get SO's search or Google to find the damn thing.
这篇关于C++ 中何时引入了“and"和“or"替代标记?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!