Hi there
I'm using an old 7.5.0/R2007b version of Matlab, and I'm experiencing a problem when reading structures created by an external C++ function.
I'm calling the function
struct_new* GetStruct_new(uint16 const val);
via loadlibrary and calllib. I'm also using a prototype file to circumvent a packing problem I had some months ago.
The structure is declared as follows in C++ code:
typedef struct{ float32 u16_Upper; float32 u16_Lower; float32* pf32_Parameters;}match_s;typedef struct{ uint16 u16_Start; uint16 u16_End; match_s* ps_1st_Match; match_s* ps_2nd_Match;}results_s;typedef struct{ uint16 u16_Depth; uint16 u16_Width; uint16 u16_Height; uint16* pu16_InData; uint16* pu16_OutData; results_s s_Results[256]; uint8 bla[256]; uint8* blubb[256];}struct_new;
…and in the prototype file:
structs.match_s.packing=4;structs.match_s.members=struct('u16_ED_Upper', 'single', 'u16_ED_Lower', 'single', 'pf32_ED_Parameters', 'singlePtr');structs.results_s.packing=4;structs.results_s.members=struct('u16_Start', 'uint16', 'u16_End', 'uint16', 'ps_1st_Match', 'match_sPtr', 'ps_2nd_Match', 'match_sPtr');structs.struct_new.packing=4;structs.struct_new.members=struct('u16_Depth', 'uint16', 'u16_Width', 'uint16', 'u16_Height', 'uint16', 'pu16_InData', 'uint16Ptr', 'pu16_OutData', 'uint16Ptr', 's_Results', 'results_s#256', 'bla', 'uint8#256', 'blubb', 'uint8Ptr#256');
In Matlab I do the following:
>> addpath ('\\projects\Binford\KX-2500\')>> loadlibrary ('KX_drives.dll', @KX-2500, 'alias', 'KX');>> params = calllib('KX', 'GetStruct_new', 11);>> par = get(params, 'Value');>> par.s_Resultsans =libpointer
This libpointer is my problem, as I have no clue how to resolve it into an array of s_Result structures and read/write them. I've searched the documentation, but I wasn't able to find something that could help me on this one; most exapmles were about creating pointers, not the opposite way.
Thanks in advance!
Best Answer