我认为这是C 11标准中的(次要)缺陷.在[dcl.dcl]中我们有:
simple-declaration:
decl-specifier-seqopt init-declarator-listopt ;
decl-specifier-seq不能是可选的.
例如,下面的代码片段无法编译:
x;
如果我在这里是正确的,那么第8.3 / 1段的开头也应该改变:
从:
A list of declarators appears after an optional (Clause 7) decl-specifier-seq (7.1).
至:
A list of declarators appears after a decl-specifier-seq (7.1).
解决方法
评论太久了
在第7条第3款中:
In a simple-declaration,the optional init-declarator-list can be omitted only when declaring a class (Clause 9) or enumeration (7.2), that is,when the decl-specifier-seq contains either a class-specifier,an elaborated-type-specifier with a class-key (9.1), or an enum-specifier. In these cases and whenever a class-specifier or enum-specifier is present in the decl-specifier-seq,the identifiers in these specifiers are among the names being declared by the declaration (as class-names,enum-names,or enumerators,depending on the syntax). In such cases,and except for the declaration of an unnamed bit-field (9.6),the decl-specifier-seq shall introduce one or more names into the program,or shall redeclare a name introduced by a previous declaration.
并在第7条第9款中
Only in function declarations for constructors,destructors,and type conversions can the decl-specifier-seq be omitted.
(编辑:李大同)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|