我有一个使用VS2010 C#构建的简单.NET dll,它暴露了一个类的2个静态成员
public class Polygon
{
public static void Test(int test) {}
public static void Test(List<int> test) {}
}
Run Code Online (Sandbox Code Playgroud)
然后我从VS2010 C++创建了一个Console应用程序,并在_tmain上面添加了这个函数
extern "C" void TestMe()
{
Polygon::Test(3);
}
Run Code Online (Sandbox Code Playgroud)
添加引用和编译会给我这个错误
1>WierdError.cpp(9): error C2526: 'System::Collections::Generic::List<T>::GetEnumerator' : C linkage function cannot return C++ class 'System::Collections::Generic::List<T>::Enumerator'
1> with
1> [
1> T=int
1> ]
1> WierdError.cpp(9) : see declaration of 'System::Collections::Generic::List<T>::Enumerator'
1> with
1> [
1> T=int
1> ]
1> WierdError.cpp(9) : see reference to class generic instantiation 'System::Collections::Generic::List<T>' being compiled
1> with …Run Code Online (Sandbox Code Playgroud)