2015-07-21 34 views
2

的extern DECL说明符考虑下面的程序:计划在一个类定义

extern class A; 

int main() {} 

是根据C++标准的这口井,形成的呢?如果它不合格需要诊断程序?我得到不同的编译器不同的结果:

+1

供应商通常将警告定义为诊断。就标准兼容性而言,将编译器消息分类为错误和警告(或编译器可能发出的任何其他内容)是毫无意义的。 –

+0

是的,你是对的,带有pedantic错误,我为Clang和GCC都收到了错误。 – Supremum

+0

Clang还提供'-Weverything'而GCC则不提供。 – Chnossos

回答

2

根据第7.1.1节/ 1的程序被非法的构造:

If a storage-class-specifier appears in a decl-specifier-seq, […] the init-declarator-list of the declaration shall not be empty (except for an anonymous union declared in a named namespace or in the global namespace, which shall be declared static (9.5)).