LINUX.ORG.RU

История изменений

Исправление quasimoto, (текущая версия) :

The declaration of a static data member in its class definition is not a definition and may be of an incomplete type other than cv-qualified void. The definition for a static data member shall appear in a namespace scope enclosing the member’s class definition.

There shall be exactly one definition of a static data member that is odr-used (3.2) in a program; no diagnostic is required.

Static data members of a class in namespace scope have external linkage

A function template, member function of a class template, or static data member of a class template shall be defined in every translation unit in which it is implicitly instantiated (14.7.1) unless the corresponding specialization is explicitly instantiated (14.7.2) in some translation unit; no diagnostic is required.

A definition for a static data member may be provided in a namespace scope enclosing the definition of the static member’s class template.

A class, a function or member template specialization can be explicitly instantiated from its template. A member function, member class or static data member of a class template can be explicitly instantiated from the member definition associated with its class template.

http://stackoverflow.com/a/7109126

В любом случае, эту ошибку должен отлавливать компилятор, а не линкер.

Как он её будет отлавливать, если он этого делать не должен и не может? Или он не должен уметь g++ -c a1.cc? Это противоречит.

Исходная версия quasimoto, :

The declaration of a static data member in its class definition is not a definition and may be of an incomplete type other than cv-qualified void. The definition for a static data member shall appear in a namespace scope enclosing the member’s class definition.

There shall be exactly one definition of a static data member that is odr-used (3.2) in a program;

no diagnostic is required.

Static data members of a class in namespace scope have external linkage

A function template, member function of a class template, or static data member of a class template shall be defined in every translation unit in which it is implicitly instantiated (14.7.1) unless the corresponding specialization is explicitly instantiated (14.7.2) in some translation unit; no diagnostic is required.

A definition for a static data member may be provided in a namespace scope enclosing the definition of the static member’s class template.

A class, a function or member template specialization can be explicitly instantiated from its template. A

member function, member class or static data member of a class template can be explicitly instantiated from the member definition associated with its class template.

http://stackoverflow.com/a/7109126

В любом случае, эту ошибку должен отлавливать компилятор, а не линкер.

Как он её будет отлавливать, если он этого делать не должен и не может? Или он не должен уметь g++ -c a1.cc? Это противоречит.