1 <!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 3.2//EN">
4 <TITLE> [IRCServices Coding] GCC3
6 <LINK REL=
"Index" HREF=
"index.html" >
7 <LINK REL=
"made" HREF=
"mailto:ircservices-coding%40ircservices.za.net?Subject=%5BIRCServices%20Coding%5D%20GCC3&In-Reply-To=3c7b4174.04007%40achurch.org">
8 <META NAME=
"robots" CONTENT=
"index,nofollow">
9 <META http-equiv=
"Content-Type" content=
"text/html; charset=us-ascii">
10 <LINK REL=
"Previous" HREF=
"000343.html">
11 <LINK REL=
"Next" HREF=
"000347.html">
13 <BODY BGCOLOR=
"#ffffff">
14 <H1>[IRCServices Coding] GCC3
</H1>
16 <A HREF=
"mailto:ircservices-coding%40ircservices.za.net?Subject=%5BIRCServices%20Coding%5D%20GCC3&In-Reply-To=3c7b4174.04007%40achurch.org"
17 TITLE=
"[IRCServices Coding] GCC3">griever at t2n.org
19 <I>Tue Feb
26 00:
19:
38 PST
2002</I>
21 <LI>Previous message:
<A HREF=
"000343.html">[IRCServices Coding] GCC3
23 <LI>Next message:
<A HREF=
"000347.html">[IRCServices Coding] GCC3
25 <LI> <B>Messages sorted by:
</B>
26 <a href=
"date.html#345">[ date ]
</a>
27 <a href=
"thread.html#345">[ thread ]
</a>
28 <a href=
"subject.html#345">[ subject ]
</a>
29 <a href=
"author.html#345">[ author ]
</a>
34 <PRE>On Tue,
26 Feb
2002, Andrew Church wrote:
36 ><i> >Plus if you did this:
38 </I>><i> >struct {
39 </I>><i> > int8_t byte;
40 </I>><i> > /*
8 bits of padding */
41 </I>><i> > int16_t word1, word2;
42 </I>><i> > /*
16 bits of padding! */
43 </I>><i> >} bar;
45 </I>><i> >it pads the extra
16 bits so it's on a
32 bit boundary.
47 </I>><i> Um, no it doesn't:
48 </I>You're right. Unlike some compilers, GCC doesn't pad types
49 at the end. It still aligns statics and autos on the
32 bit
50 boundary, but if you malloced it, there would still be the extra
54 </I>><i> #include
<sys/types.h
>
56 </I>><i> int8_t byte;
57 </I>><i> int16_t word1, word2;
59 </I>><i> main() { printf(
"%d\n
", sizeof(bar)); }
61 </I>><i> "6" is printed:
1 byte +
1 byte of padding +
2*
2 bytes.
62 </I>wierd, I always though structs were multiples of
4 bytes.
64 </I>><i> (Incidentally, it looks like you're right on the double/long long
65 </I>><i> issue; my apologies.)
67 </I>><i> --Andrew Church
68 </I>><i> <A HREF=
"http://www.ircservices.za.net/mailman/listinfo/ircservices-coding">achurch at achurch.org
</A>
69 </I>><i> <A HREF=
"http://achurch.org/">http://achurch.org/
</A>
70 </I>><i> ------------------------------------------------------------------
71 </I>><i> To unsubscribe or change your subscription options, visit:
72 </I>><i> <A HREF=
"http://www.ircservices.za.net/mailman/listinfo/ircservices-coding">http://www.ircservices.za.net/mailman/listinfo/ircservices-coding
</A>
82 <LI>Previous message:
<A HREF=
"000343.html">[IRCServices Coding] GCC3
84 <LI>Next message:
<A HREF=
"000347.html">[IRCServices Coding] GCC3
86 <LI> <B>Messages sorted by:
</B>
87 <a href=
"date.html#345">[ date ]
</a>
88 <a href=
"thread.html#345">[ thread ]
</a>
89 <a href=
"subject.html#345">[ subject ]
</a>
90 <a href=
"author.html#345">[ author ]
</a>