[IRCServices Coding] GCC3
Finny Merrill
griever at t2n.org
Tue Feb 26 00:19:38 PST 2002
On Tue, 26 Feb 2002, Andrew Church wrote:
> >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:
You're right. Unlike some compilers, GCC doesn't pad types
at the end. It still aligns statics and autos on the 32 bit
boundary, but if you malloced it, there would still be the extra
16 bits.
>
> #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.
wierd, I always though structs were multiples of 4 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/
> ------------------------------------------------------------------
> To unsubscribe or change your subscription options, visit:
> http://www.ircservices.za.net/mailman/listinfo/ircservices-coding
>