编译器错误 C2894
模板不能声明为具有“C”链接
引起此错误的原因可能是模板在 extern "C"
块内定义。
以下示例生成 C2894:
// C2894.cpp
extern "C" {
template<class T> class stack {}; // C2894 fail
template<class T> void f(const T &aT) {} // C2894
}
以下示例生成 C2894:
// C2894b.cpp
// compile with: /c
extern "C" template<class T> void f(const T &aT) {} // C2894
template<class T> void f2(const T &aT) {} // OK
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈