M
Michael B Allen
My understanding is that struct members will remain in order such that
the following can be used to support variable sized members:
struct indexed_values {
int *values;
unsigned char bitset[0];
};
struct meta_data {
struct indexed_values foo;
unsigned char _foo_bs[8];
struct indexed_values bar;
unsigned char _bar_bs[16];
struct indexed_values zap;
unsigned char _zap_bs[4];
....
};
In this case accessing meta_data->bar[15] for example cannot overlap
with other members of runover into the zap member.
Is this legitimate C?
Thanks,
Mike
the following can be used to support variable sized members:
struct indexed_values {
int *values;
unsigned char bitset[0];
};
struct meta_data {
struct indexed_values foo;
unsigned char _foo_bs[8];
struct indexed_values bar;
unsigned char _bar_bs[16];
struct indexed_values zap;
unsigned char _zap_bs[4];
....
};
In this case accessing meta_data->bar[15] for example cannot overlap
with other members of runover into the zap member.
Is this legitimate C?
Thanks,
Mike