gpt4 book ai didi

c++ - dll 中的类型无效,但我没有看到错误

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:12:45 26 4
gpt4 key购买 nike

CAPL_DLL_INFO4 table[] = {
{CDLL_VERSION_NAME, (CAPL_FARCALL)CDLL_VERSION, "", "", CAPL_DLL_CDECL, 0xabcd, CDLL_EXPORT },

...
{"dllTEST",(CAPL_FARCALL)GetAttribute,"CAPL_DLL","...",'I', 5, "IIICI", "\001\001\001\100\001",{ "x","x","x","x","x" } },
...

{0, 0}
};
CAPLEXPORT CAPL_DLL_INFO4 far * caplDllTable4 = table;

这是我在源文件中的 CAPL 导出表,它是用 c++ 编写的,并且编译时没有错误或警告到 *.dll。在我的定义和原型(prototype)中,函数接口(interface)看起来像这样:

int CAPLEXPORT far CAPLPASCAL GetAttribute(int16 a, int16 b, int16 c, char d[], int16 e);

将*.dll成功实现到CANoe后,我在CANoe中得到编译错误:

CAPL node 'ECU 1': Compilation of '..\ecu.can' failed with error(s)
Invalid type in DLL ..\abc.dll, function dllTEST.

我是否遗漏了一些明显的东西?在 this 中,函数中使用的类型都被精细地转换为符合 CAPL 的类型pdf 第 15 页,您可以阅读有关错误的信息:

This error is caught while compiling a CAPL program. The function defined in the CAPL Export Table is incorrect. Most of the time it is the parameter settings in the CAPL Export Table.

最佳答案

根据"Implementing and Integrating CAPL DLLs"手册,您的函数声明和函数表应如下所示:

long CAPLEXPORT far CAPLPASCAL GetAttribute(long a, long b, long c, char d[], long e);

CAPL_DLL_INFO table[] = {
{CDLL_VERSION_NAME, (CAPL_FARCALL)CDLL_VERSION, CAPL_DLL_CDECL, 0xabcd, CDLL_EXPORT},
...
{"dllTEST", (CAPL_FARCALL)GetAttribute, 'L', 5, "LLLCL", "\000\000\000\001\000"},
...
{0, 0}
};

unsigned long CAPLEXPORT __cdecl caplDllGetTable(void)
{
return (unsigned long)table;
}

说明

  1. 因为只有第 4 个参数 (d) 是一个数组(一维),所以数组深度定义是:

    "\000\000\000\001\000"
  2. 不要使用 int16。使用表 3(函数参数和返回值数据类型)中描述的类型。由于 intchar 只能在数组大小 !=0 时使用,因此我们使用 long

关于c++ - dll <dllname.dll><functionname> 中的类型无效,但我没有看到错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38298329/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com