Hacker News new | past | comments | ask | show | jobs | submit login

With the caveat that structs are padded by default so that members are aligned on architecture-friendly boundaries.

For example, if a struct contains a char a followed by an int b, typically b would be at offset 4, even though sizeof(a) is 1.

To get tight packing, you need to explicitly tell the compiler to disable padding.




That's why where is __attribute__((packed))




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: