Hacker News new | ask | show | jobs
by tialaramex 21 days ago
Can you say more, maybe with an example of what goes wrong? I can't picture this in my head, when I picture translating some struct it feels like this works just fine, clearly I am missing something from what you're imagining.
1 comments

E.g. you cannot translate `#[repr(C)] struct Foo { v: i32, u: i32 }` to `typedef struct { int32_t v; int32_t u; } Foo;` because in Rust it's entirely valid to take a `&Foo` and view it as `&[i32; 2]`, while in C this is UB.
Isn't the alignment for the struct and the array the same, because it is determined by the inner type?