Re:The Lost Art of Structure Packing (2018)
by dan-robertson on Monday April 27, 2020 @10:06AM
(#22995924)
This is hard. If your struct definition is in a header file then the compiler needs to generate correct field offsets for anything that includes that header file, so it would need to always optimally pack structure the same way based only on the definition and not on the usage.
People will also do silly things like casting between types in ways that rely on similarly written structures having similar memory layouts. So C is probably a bad language to turn this on by default in
People will also do silly things like casting between types in ways that rely on similarly written structures having similar memory layouts. So C is probably a bad language to turn this on by default in