加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

我认为这是C 11标准中的(次要)缺陷

发布时间:2020-12-16 04:56:47 所属栏目:百科 来源:网络整理
导读:我认为这是C 11标准中的(次要)缺陷.在[dcl.dcl]中我们有: simple-declaration : decl-specifier-seq opt init-declarator-list opt ; decl-specifier-seq不能是可选的. 例如,下面的代码片段无法编译: x; 如果我在这里是正确的,那么第8.3 / 1段的开头也应该
我认为这是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.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读