|
|
|
|
|
by Hemospectrum
748 days ago
|
|
> Does Rust fundamentally guarantee that if you make a struct, its fields will lay out in memory in the order that you defined them? Can it be used to interact with APIs (really ABIs) who expect a C struct (or pointer to one)? You have to specify this behavior with #[repr(C)]. Otherwise, the compiler will rearrange fields to try to optimize packing and alignment. |
|
https://doc.rust-lang.org/reference/type-layout.html
https://github.com/rust-lang/compiler-team/issues/457