[출처 : http://ryu2811.tistory.com/23]
__attribute__ ((packed)) : 구조체 내의 최대 사이즈 데이터 타입으로 alignment 하지
않도록한다.
************************************************************
#include
<stdio.h>
typedef struct _test_t_
{
unsigned char uc1;
unsigned char
uc2;
unsigned long long ui1;
} test_t;
typedef struct _testp_t_
{
unsigned char uc1;
unsigned
char uc2;
unsigned long long ui1;
} __attribute__ ((packed))
testp_t;
int main (void)
{
test_t t1;
testp_t t2;
printf ("test_t : %d\n", sizeof (t1));
printf ("testp_t : %d\n",
sizeof (t2));
return
0;
}
************************************************************
[ryu2811@qwertyryu-home
~/work/src/test] ./kkk
test_t : 16
testp_t : 10