使用dllexport时出错

Error when using dllexport?

本文关键字:出错 dllexport 使用      更新时间:2023-10-16

我想使用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) ;
}

我试图将_stdcall更改为__clrcall,但它出现了另一个错误:

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

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

谢谢,

T&T组

编译器已经告诉你问题出在哪里了

__declspec(dllexport) array<char>^ __stdcall WrappedC(int i)

不能使用__declspec(dllexport),因为该函数正在使用clr

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