Hi Philip,
I made a little progress since two days ago. I thought about packing, too, but since the dll worked nice for some time with gaps in it I didn't follow this direction at first.
Anyway, using #pragma pack I could change the packing of the structure in the C-Code, but MatLab always returned the same structsize regardless of the packing factor (I did use only the header file, not a custom loader file).
For now, I've filled the gaps in the structure with dummy values and changed one pointer to an array. The stability is much better now, but I have a new problem with the array.
The structure now looks like this in C-code (truncated, the remaining code is as above):
(...
//Byte offset in structure (decimal)
uint16 u16_ED_Height; // 64
uint16 fill_6; // 66 - a dummy/fill value
float32 f32_Sigma[8]; // 68
uint8 u8_Meta; //100
uint8 u8_ED_Upper; //101
uint8 u8_ED_Lower; //102
uint8 fill_7; //103
(...
Until fill6 MatLab interprets the structure fine, but it reads the first value of array Sigma at offset 72, not 68, the second at 76 instead of 72, and so on. The 4 byte difference continues for the rest of the structure. The data at offset 68 on the other hand is omitted.
Any idea?
Best Answer