2015-07-21 35 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)).