struct test{
char a;//1
int b;//4
long c;//4
void* d;//1
int e;//4
char* f;//4
};
int main(){
struct test t1;
printf(t1.f);
}
gcc -g test.c(需要使用-g来生成符号表)
(gdb) file a.out
Reading symbols from a.out...done.
(gdb) p sizeof(struct test)
$8 = 24
正常struct的大小应该为: 4+4+4+4 + 1+1=18;
但由于结构体是8字节对齐的,可以看到结构体大小为24;