3 ms·
No. A huge and important use of structs is to communicate with other things, like hardware, libraries, and other languages, and in in those cases it's very imp
by jlarocco 10y ago
No.
A huge and important use of structs is to communicate with other things, like hardware, libraries, and other languages, and in in those cases it's very important that the struct matches what the other side expects. You don't want the compiler to rearrange your TCP packet, for example.
It might make sense to have a compiler extension to optimize packing for internal-only data structures, but I doubt any compilers bother. It's just another entry on the long list of things that C assumes the programmer will do themselves if it's important to them.