Problem while generating a pointer to a struct (a field of the struct is a pointer to a function)

2 ビュー (過去 30 日間)
I would like to create a pointer to a struct and then use it as an input in *.dll function call. Some fields of the struct are numbers but a few of them are function pointers (fcnPtr).
Please have a look in below pseudo-code:
loadlibrary('myLib.dll', 'my_header.h', 'mfilename', 'myLibbit.m')
myStruct.dev_id = uint8(1);
myStruct.read = @myReadFunction; % Function handle
myStructMatlab = libstruct('struct_name', myStruct);
myStructMatlabPt = libpointer('struct_namePtr', myStructMatlab);
I get the following error:
Cannot convert data value for field read due to error:
Array must be numeric or logical or a pointer to one
Error in libstruct (line 16)
ptr=feval(['lib.' structtype],initialvalue);
In case that I do not use the field myStruct.read the above process works fine. Is there a way to solve the above issue?

回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by