“class”:type-class-id 被重新定义为全局数据变量
不能将泛型或模板类用作全局数据变量。
此错误在 Visual Studio 2022 及更高版本中已过时。
如果大括号匹配不正确,则可能导致此错误。
下面的示例生成 C2936:
// C2936.cpp
// compile with: /c
template<class T> struct TC { };
int TC<int>; // C2936
// OK
struct TC2 { };
int TC2;
使用泛型时,也可能会生成 C2936:
// C2936b.cpp
// compile with: /clr /c
generic<class T>
ref struct GC {};
int GC<int>; // C2936
// OK
ref struct GC2 {};
int GC2;