Systems demand that certain primitives be aligned to certain points within the memory (ints to bits that are multiples of 4, shorts to bits that are multiples of 2, etc.). Of course, these can be optimized to waste the least space in padding.
my question is why doesn't GCC do this automatically? Is the more obvious heuristic (order variables from biggest size requirement to smallest) lacking in some way? Is some code dependent on the physical ordering of its structs (/is that a good idea)?
I'm only asking because GCC is super optimized in a lot of ways but not in this one, and I'm thinking there must be some relatively cool explanation (to which I am oblivious).
Thanks
Alex