Filter löschen
Filter löschen

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

1 Ansicht (letzte 30 Tage)
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?

Antworten (0)

Kategorien

Mehr zu Structures finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by