Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Is there a way to request that the compiler not do this on a per-structure basis?


There's a #[repr(C)] annotation that can be placed on a struct, IIRC.


That guarantees the same layout that C would have for that struct. There is also #[repr(packed)] which puts things as close as possible without alignment, and then you can insert padding manually with fields of type [u8; N] where N is the number of bytes.




Consider applying for YC's Winter 2027 batch! Applications are open till November 2.

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

Search: