4 ms·
I'm not a C programmer, but isn't there some directive you can add to a union to tightly pack it, or specify member memory locations or something? So that then
by OskarS 9y ago
I'm not a C programmer, but isn't there some directive you can add to a union to tightly pack it, or specify member memory locations or something? So that then you could guarantee that for the Some struct, `ptrdiff_t tag;` starts at offset 0 and the union starts at offset `sizeof(ptrdiff_t)`?
- clarry 9y agoThat doesn't help if your architecture doesn't support unaligned access. The compiler is allowed to insert padding for a good reason, and packing is rarely the right solution for anything.