typedef struct {
uint8_t type :1;
uint8_t attr :3;
uint16_t value :12;
}__attribute__((packed)) standard_t
typedef struct {
uint8_t type :1;
uint8_t attr :2;
uint8_t attr2 :3;
uint16_t value :9;
}__attribute__((packed)) extended_t;
typedef struct {
uint16_t dummy;
} dummy_t;
typedef union {
standard_t std;
dummy_t ext;
} data_t;
이런 data structure가 있는 경우에,
data_t dat;
extended_t ext;
ext.type = 1;
..
dat.ext = *(uint16_t*)&ext;
이렇게 했을 때 dat.std.type을 접근해도 dat.ext.type을 접근하는 것과
동일하다는 것이 보장되나요?..
즉, extended_t의 type과 standard_t의 type이 data_t structure안에서
같은 bit offset을 가지게 되는 것이 보장되나요?
intel machine+linux(gcc 2.95) 조합에서는 되던데 문서를 찾아봐도
관련 내용이 없어서요.. variable의 structure내에서의 순서도 바뀌는 것 같고..