Hmm, interesting. I also would have thought that in a union-type, all variables start at offset zero.
I thought i have seen it used something like this (pseudo-code, my C coding days are mostly over so i'm not really sure how this is all supposed to look): Image you want to have different IP records in memory, say,
typedef struct {
uint32 type;
char ip[4];
} ipv4;
typedef struct {
uint32 type;
char ip[16];
} ipv6;
Then you would be able to have an union type of both and access the first field ("type") to cast the variable to the the correct typedef?
As said, my C coding days are mostly over. But since i have some XS work coming up, i might as well start to think about such problems right now :-)
"For me, programming in Perl is like my cooking. The result may not always taste nice, but it's quick, painless and it get's food on the table."