I'm doing C++ --> C# interop stuff and I have a bunch of structs that contain each other like Matryoshka dolls. The problem is that one of these 'nestings' takes the form of a fixed length array:
typedef struct tagBIRDREADING
{
BIRDPOSITION position;
BIRDANGLES angles;
BIRDMATRIX matrix;
BIRDQUATERNION quaternion;
WORD wButtons;
}
BIRDREADING;
typedef struct tagBIRDFRAME
{
DWORD dwTime;
BIRDREADING reading[BIRD_MAX_DEVICE_NUM + 1];
}
BIRDFRAME;
Following the hallowed teachings of Eric Gunnerson, I did the following in C#:
[StructLayout(LayoutKind.Sequential, Pack = 0)]
public struct BIRDREADING
{
public BIRDPOSITION position;
public BIRDANGLES angles;
public BIRDMATRIX matrix;
public BIRDQUATERNION quaternion;
public ushort wButtons;
}
[StructLayout(LayoutKind.Sequential, Size = 127)]
public struct BIRDREADINGa
{
public BIRDREADING reading;
}
public struct BIRDFRAME
{
public uint dwTime;
public BIRDREADINGa readings;
}
My question is, how do I access each of the 127 instances of BIRDREADING contained within BIRDREADINGa and therefore BIRDFRAME? Or have I gone terrible wrong?