Condividi tramite


Errore del compilatore C2940

'class': type-class-id ridefinito come typedef locale

Non è possibile usare una classe generica o modello come locale typedef.

Questo errore è obsoleto in Visual Studio 2022 e versioni successive.

L'esempio seguente genera l'errore C2940:

// C2940.cpp
template<class T>
struct TC {};
int main() {
   typedef int TC<int>;   // C2940
   typedef int TC;   // OK
}

C2940 può verificarsi anche quando si usano i generics:

// C2940b.cpp
// compile with: /clr
generic<class T>
ref struct GC { };

int main() {
   typedef int GC<int>;   // C2940
   typedef int GC;
}