编译器错误 C2921
重定义:“class”:类 template 或 generic 重新声明为“type”
generic 或 template 类具有多个不等效的声明。 要解决此错误,请对不同的类型使用不同的名称,或删除类型名称的重定义。
以下示例生成 C2921:
// C2921.cpp
// compile with: /c
template <class T> struct TC2 {};
typedef int TC2; // C2921
// try the following line instead
// typedef struct TC2<int> x; // OK - declare a template instance
使用 generic 时,也可能发生 C2921。
// C2921b.cpp
// compile with: /clr /c
generic <class T> ref struct GC2 {};
typedef int GC2; // C2921
// try the following line instead
// typedef ref struct GC2<int> x;
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈