フィルターのクリア

Does passing enumerated types to calllib only work up to enum values of 0x80000000?

1 回表示 (過去 30 日間)
Johan Backström
Johan Backström 2014 年 10 月 20 日
コメント済み: Cris Luengo 2022 年 12 月 19 日
I am calling a function in a DLL to get hold of the value corresponding to a certain enum name defined in a C header file. This DLL function simply looks like this:
EXPORTED unsigned long convertEnumNameToU32(LinIfParamName parameterName)
{
return (unsigned long)parameterName;
}
The enum definition in the C header file looks like this:
typedef enum LinIfParamName
{
DUMMY0 = 0x7FFFFFFD,
DUMMY1 = 0x7FFFFFFE,
DUMMY2 = 0x7FFFFFFF,
DUMMY3 = 0x80000000,
DUMMY4 = 0x80000001,
DUMMY5 = 0x80000002
} LinIfParamName;
Now, after loading the DLL with loadlibrary and calling the conversion function through calllib, like
calllib(obj.dpdLibraryName, 'convertEnumNameToU32', 'DUMMY0')
I only get the correct value returned for the first four enum names. All enum names having a value larger than 0x80000000 is returned as 0x80000000.
Is this a known limitation in loadlibrary or calllib?
  1 件のコメント
Cris Luengo
Cris Luengo 2022 年 12 月 19 日
An enum is an int, 0x7FFFFFFF is the largest possible value in an int. MATLAB doesn't wrap on overflow, it clamps. I'm guessing this issue is related to that.

サインインしてコメントする。

回答 (1 件)

Stalin Samuel
Stalin Samuel 2014 年 10 月 20 日
  1 件のコメント
Johan Backström
Johan Backström 2014 年 10 月 20 日
I can't find an answer to my question on that link which describes working with enumerations directly in matlab. My question concerns passing enumeration types by string to a C shared library. http://www.mathworks.se/help/matlab/matlab_external/pass-enumerated-types.html#btf6lke-1

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeString についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by