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

我认为这是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.

相关文章

/** C+⬑ * 默认成员函数 原来C++类中,有6个默认成员函数: 构造函数 析构函数 拷贝...
#pragma once // 1. 设计一个不能被拷贝的类/* 解析:拷贝只会放生在两个场景中:拷贝构造函数以及赋值运...
C类型转换 C语言:显式和隐式类型转换 隐式类型转化:编译器在编译阶段自动进行,能转就转,不能转就编译...
//异常的概念/*抛出异常后必须要捕获,否则终止程序(到最外层后会交给main管理,main的行为就是终止) try...
#pragma once /*Smart pointer 智能指针;灵巧指针 智能指针三大件//1.RAII//2.像指针一样使用//3.拷贝问...
目录<future>future模板类成员函数:promise类promise的使用例程:packaged_task模板类例程...