[IRCServices Coding] GCC3

Andrew Church achurch at achurch.org
Tue Feb 26 17:02:24 PST 2002


>Plus if you did this:
>
>struct {
>  int8_t byte;
>  /* 8 bits of padding */
>  int16_t word1, word2;
>  /* 16 bits of padding! */
>} bar;
>
>it pads the extra 16 bits so it's on a 32 bit boundary.

     Um, no it doesn't:

#include <sys/types.h>
struct {
    int8_t byte;
    int16_t word1, word2;
} bar;
main() { printf("%d\n", sizeof(bar)); }

"6" is printed: 1 byte + 1 byte of padding + 2*2 bytes.

     (Incidentally, it looks like you're right on the double/long long
issue; my apologies.)

  --Andrew Church
    achurch at achurch.org
    http://achurch.org/