模板不能声明为有“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
转自:http://msdn.microsoft.com/zh-cn/library/vstudio/95bhc9c2.aspx