使用dllexport时出错?

TTG*_*oup 5 .net c++ managed-c++ dllexport

我想使用 dllexport 导出函数。但是我在编译器“错误 C4439:'WrappedC':签名中具有托管类型的函数定义必须具有 __clrcall 调用约定”时遇到了错误。

我在头文件(.h)中的代码是:

extern "C" 
{

__declspec(dllexport) int __stdcall ABC(int i);
__declspec(dllexport) char* __stdcall C(int i);
__declspec(dllexport) array<char>^ __stdcall WrappedC(int i) ;

}
Run Code Online (Sandbox Code Playgroud)

我尝试将 _stdcall 更改为 __clrcall 但又出现另一个错误:

error C3395: 'WrappedC' : __declspec(dllexport) cannot be applied to a function with the __clrcall calling convention
Run Code Online (Sandbox Code Playgroud)

我在网上搜索过,但还没有解决。

谢谢,

大统华集团

Ale*_*eks 2

编译器已经告诉你问题是什么了。

__declspec(dllexport) array<char>^ __stdcall WrappedC(int i)
Run Code Online (Sandbox Code Playgroud)

您无法使用__declspec(dllexport),因为该函数正在使用clr.

array<char>^几乎是它抱怨的部分,因为它不是本机代码。