I have a struct with 2 members of type double and 1 member of type long.
The sizeof() function returns 24. Normaly it should be 20(2*8bytes for the doubles and 4 bytes for the long).
When I add a another member of type long sizeof() returns 32.
Another struct with 3 longs returns 12 with sizeof().
I suppose it has something to do with allignment and optimalisation? How can I avoid this.
Luc Vercruysse
If you really need to get rid of the 'holes' in your structure, then you should consider 'packing' them.
Refer to:
www.keil.com/.../armccref_cjafjhjd.htm
Note that doing this can have a negative effect on code speed and size.
yes, because the compiler *must* assume each assess to the structure might be unaligned, which means extra shifts.
Thanks for very fast reply !!!