CompuServe Messages

C structure size

    04-Jun-90 13:06:50
Sb: #107610-C structure size
Fm: Mike Spille/Manx 71545,1466
To: John Draper 76703,4322
All structures are always padded to word alignment on 68k compilers. The reason of course is to ensure that you don't access an int or long on an odd-address boundary by mistake. For example: struct foo { int a; char b; } bar[2]; Here, the sizeof(struct foo) _must_ be 4 (assuming 16-bit ints, of course 8-), so that when you say bar[1].a you're getting the 'a' element on an even boundary. -Mike