不能使用“不是”,“或”,或“加”作为标识符? [英] Can't use "not", "or", or "plus" as identifier?
问题描述
我试着编译这个:
enum class conditional_operator { plus, or, not };
但是显然GCC(4.6)认为这些都是特殊的,而我找不到一个标准它们(不是C ++ 0x n3290或C99 n2794)。我正在编译 g ++ -pedantic -std = c ++ 0x
。这是一个编译器方便吗?如何关闭它?不应 -std = c ++ 0x
关闭此功能?
But apparently GCC (4.6) thinks these are special, while I can't find a standard that says they are (neither C++0x n3290 or C99 n2794). I'm compiling with g++ -pedantic -std=c++0x
. Is this a compiler convenience? How do I turn it off? Shouldn't -std=c++0x
turn this "feature" off?
PS:Hmmm,显然,MarkDown代码格式化也认为这样...
PS: Hmmm, apparently, MarkDown code formatting thinks so too...
推荐答案
看看2.5。它们是 ||
和!
的替代标记。
Look at 2.5. They are alternative tokens for ||
and !
.
有一堆其他替代令牌BTW。
There is a bunch of other alternative tokens BTW.
编辑:它们的包含的原理是一样的trigraphs:允许使用非ASCII字符集。委员会试图摆脱它们(至少是三字母,我不记得替代令牌),并遇到了人们(大多数是IBM大型机用户)使用它们的反对。
The rationale for their inclusion is the same as the one of trigraphs: allow the use of non ASCII character sets. The committee has tried to get rid of them (at least of trigraphs, I don't remember for alternative tokens), and has met opposition of people (mostly IBM mainframe users) which are using them.
编辑完整性:as other have make the remarks,plus不在该类中,除非你是 using namespace std
。
Edit for completeness: as other have make the remarks, plus isn't in that class and should not be a problem unless you are using namespace std
.
这篇关于不能使用“不是”,“或”,或“加”作为标识符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!