>> Delete No. 57079 article
No. gcc extension인 attribute packed를 사용하는 경우..

등록 2002-09-14 19:46:00 By localhost     조회 5
이름 서지원    

		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내에서의 순서도 바뀌는 것 같고..
[관리자] 패스워드를 입력 하십시오. 답장이 존재하면 함께 삭제됩니다.[ 목록 | 이전 ]
패스워드:    

Copyleft 1999-2026 by JSBoard Open Project
Theme Designed by IDOO All right reserved