dll <dllname.dll><functionname> 中的类型无效,但我没有看到错误

Invalid type in dll <dllname.dll><functionname> but I don't see the error

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", "[=12=]1[=12=]1[=12=]10[=12=]1",{ "x","x","x","x","x" } },
  ...

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

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

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.

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

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" 手册,您的函数声明和函数 table 应该如下所示:

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", "[=10=]0[=10=]0[=10=]0[=10=]1[=10=]0"},
    ...
    {0, 0}
};

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

说明

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

    "[=11=]0[=11=]0[=11=]0[=11=]1[=11=]0"
    
  2. 不要使用int16。使用 Table 3( 函数参数和 Return 值数据类型 )中描述的类型。由于 intchar 只能在数组大小 !=0 时使用,我们使用 long.