]> jfr.im git - irc.git/blob - software/!RELEASES/ircservices/achurch.org/services/lists/ircservices-coding/2002/000345.html
RELEASE -> !RELEASE
[irc.git] / software / !RELEASES / ircservices / achurch.org / services / lists / ircservices-coding / 2002 / 000345.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
2 <HTML>
3 <HEAD>
4 <TITLE> [IRCServices Coding] GCC3
5 </TITLE>
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">
12 </HEAD>
13 <BODY BGCOLOR="#ffffff">
14 <H1>[IRCServices Coding] GCC3</H1>
15 <B>Finny Merrill</B>
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
18 </A><BR>
19 <I>Tue Feb 26 00:19:38 PST 2002</I>
20 <P><UL>
21 <LI>Previous message: <A HREF="000343.html">[IRCServices Coding] GCC3
22 </A></li>
23 <LI>Next message: <A HREF="000347.html">[IRCServices Coding] GCC3
24 </A></li>
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>
30 </LI>
31 </UL>
32 <HR>
33 <!--beginarticle-->
34 <PRE>On Tue, 26 Feb 2002, Andrew Church wrote:
35
36 &gt;<i> &gt;Plus if you did this:
37 </I>&gt;<i> &gt;
38 </I>&gt;<i> &gt;struct {
39 </I>&gt;<i> &gt; int8_t byte;
40 </I>&gt;<i> &gt; /* 8 bits of padding */
41 </I>&gt;<i> &gt; int16_t word1, word2;
42 </I>&gt;<i> &gt; /* 16 bits of padding! */
43 </I>&gt;<i> &gt;} bar;
44 </I>&gt;<i> &gt;
45 </I>&gt;<i> &gt;it pads the extra 16 bits so it's on a 32 bit boundary.
46 </I>&gt;<i>
47 </I>&gt;<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
51 16 bits.
52
53 &gt;<i>
54 </I>&gt;<i> #include &lt;sys/types.h&gt;
55 </I>&gt;<i> struct {
56 </I>&gt;<i> int8_t byte;
57 </I>&gt;<i> int16_t word1, word2;
58 </I>&gt;<i> } bar;
59 </I>&gt;<i> main() { printf(&quot;%d\n&quot;, sizeof(bar)); }
60 </I>&gt;<i>
61 </I>&gt;<i> &quot;6&quot; is printed: 1 byte + 1 byte of padding + 2*2 bytes.
62 </I>wierd, I always though structs were multiples of 4 bytes.
63 &gt;<i>
64 </I>&gt;<i> (Incidentally, it looks like you're right on the double/long long
65 </I>&gt;<i> issue; my apologies.)
66 </I>&gt;<i>
67 </I>&gt;<i> --Andrew Church
68 </I>&gt;<i> <A HREF="http://www.ircservices.za.net/mailman/listinfo/ircservices-coding">achurch at achurch.org</A>
69 </I>&gt;<i> <A HREF="http://achurch.org/">http://achurch.org/</A>
70 </I>&gt;<i> ------------------------------------------------------------------
71 </I>&gt;<i> To unsubscribe or change your subscription options, visit:
72 </I>&gt;<i> <A HREF="http://www.ircservices.za.net/mailman/listinfo/ircservices-coding">http://www.ircservices.za.net/mailman/listinfo/ircservices-coding</A>
73 </I>&gt;<i>
74 </I>
75
76 </PRE>
77
78 <!--endarticle-->
79 <HR>
80 <P><UL>
81 <!--threads-->
82 <LI>Previous message: <A HREF="000343.html">[IRCServices Coding] GCC3
83 </A></li>
84 <LI>Next message: <A HREF="000347.html">[IRCServices Coding] GCC3
85 </A></li>
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>
91 </LI>
92 </UL>
93
94 </body></html>