I was just wondering about the considerations to be followed while packing items (int, float, unions, etc) in a C structure (C struct definition ) that would allow the compiler to further optimize it.
I would like to know whether there are any guidelines that one should follow e.g. adding items to the structure in an order that would allow alignments to the word boundaries. etc. ?
details would be appreciated.
The question also entails the optimization strategies towards cross compiling such C structures.
If you can compile your code under gcc, you might be able to use pahole to find structures that can be improved, and automatically repack them.
Here are a couple of articles about pahole that might help you: