I am trying to use C# to use a C++ library that includes a struct that is documented as being laid out like this:
struct {
long outervar;
long othervar;
union {
struct {
long a;
} firststruct;
struct {
long p;
long q;
long r;
long s;
} secondstruct;
struct {
long x;
long y;
long z;
} thirdstruct;
} myunion;
} outerstruct;
Ideally I would like to implement something like this:
struct outerstruct
{
UInt32 outervar;
UInt32 othervar;
[FieldOffset(0)]
struct firststruct
{
UInt32 a;
}
[FieldOffset(0)]
struct secondstruct
{
UInt32 p;
UInt32 q;
UInt32 r;
UInt32 s;
}
[FieldOffset(0)]
struct thirdstruct
{
UInt32 x;
UInt32 y;
UInt32 z;
}
}
Of course I can't use FieldOffset or MarshalAs on structs, but I am at a loss as to how to implement this. If anybody has some ideas how to implement this in C# I would appreciate it.
Thanks!