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=">
8 <META NAME=
"robots" CONTENT=
"index,nofollow">
9 <META http-equiv=
"Content-Type" content=
"text/html; charset=us-ascii">
10 <LINK REL=
"Previous" HREF=
"000350.html">
11 <LINK REL=
"Next" HREF=
"000335.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="
17 TITLE=
"[IRCServices Coding] GCC3">achurch at achurch.org
19 <I>Tue Feb
26 15:
31:
57 PST
2002</I>
21 <LI>Previous message:
<A HREF=
"000350.html">[IRCServices Coding] GCC3
23 <LI>Next message:
<A HREF=
"000335.html">[IRCServices Coding] GCC3
25 <LI> <B>Messages sorted by:
</B>
26 <a href=
"date.html#331">[ date ]
</a>
27 <a href=
"thread.html#331">[ thread ]
</a>
28 <a href=
"subject.html#331">[ subject ]
</a>
29 <a href=
"author.html#331">[ author ]
</a>
34 <PRE>>><i> Again, that's what I thought--compilers aren't supposed to pad more
35 </I>>><i> than the largest type in the structure, and between structure members only
36 </I>>><i> enough to align the next member to a multiple of its size. I'm pretty sure
37 </I>>><i> this is defined somewhere, and if not then it should be (see below).
38 </I>><i>Not the largest type in the structure, the largest *type*.
39 </I>><i>Most structures will pad to
32 bits on intel machines.
44 </I>><i> int8_t byte;
45 </I>><i> /* inserts
8 or
24 bits of padding here */
46 </I>><i> int16_t word;
47 </I>><i> /* inserts
16 bits of padding here */
48 </I>><i> int32_t dword;
49 </I>><i> /* no padding here */
50 </I>><i>} something;
52 That's missing the point; you put a
32-bit type in there, which of
53 course means it will pad to
32 bits. (And by your argument, it would have
54 to pad to at least the size of a double, not just an int32_t.) What you're
55 saying would be something like:
59 /*
24 bits of padding */
61 /*
16 bits of padding */
62 } foo; /* size =
64 bits */
64 which is stupid because you have
32 bits of wasted space, when you could
65 just as easily and with no alignment problems (at least on any CPU I know
70 /*
8 bits of padding */
72 } bar; /* size =
32 bits */
75 <A HREF=
"http://www.ircservices.za.net/mailman/listinfo/ircservices-coding">achurch at achurch.org
</A>
76 <A HREF=
"http://achurch.org/">http://achurch.org/
</A>
84 <LI>Previous message:
<A HREF=
"000350.html">[IRCServices Coding] GCC3
86 <LI>Next message:
<A HREF=
"000335.html">[IRCServices Coding] GCC3
88 <LI> <B>Messages sorted by:
</B>
89 <a href=
"date.html#331">[ date ]
</a>
90 <a href=
"thread.html#331">[ thread ]
</a>
91 <a href=
"subject.html#331">[ subject ]
</a>
92 <a href=
"author.html#331">[ author ]
</a>