<?xml version="1.0" encoding="utf-8" ?>

<rss version="2.0" 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/"
   xmlns:content="http://purl.org/rss/1.0/modules/content/"
   >
<channel>
    <title>Portability Blog (Entries tagged as gcc)</title>
    <link>http://portabilityblog.com/blog/</link>
    <description>tales about building software on many platforms</description>
    <dc:language>en</dc:language>
    <generator>Serendipity 1.2.1 - http://www.s9y.org/</generator>
    <managingEditor>df.portabilityblog@erinye.com</managingEditor>
<webMaster>df.portabilityblog@erinye.com</webMaster>
<pubDate>Fri, 29 May 2009 11:34:46 GMT</pubDate>

    <image>
        <url>http://portabilityblog.com/blog/templates/default/img/s9y_banner_small.png</url>
        <title>RSS: Portability Blog - tales about building software on many platforms</title>
        <link>http://portabilityblog.com/blog/</link>
        <width>100</width>
        <height>21</height>
    </image>

<item>
    <title>Bad register name &quot;dil&quot; (or &quot;sil&quot;)</title>
    <link>http://portabilityblog.com/blog/archives/11-Bad-register-name-dil-or-sil.html</link>
            <category>CPUs</category>
    
    <comments>http://portabilityblog.com/blog/archives/11-Bad-register-name-dil-or-sil.html#comments</comments>
    <wfw:comment>http://portabilityblog.com/blog/wfwcomment.php?cid=11</wfw:comment>

    <slash:comments>2</slash:comments>
    <wfw:commentRss>http://portabilityblog.com/blog/rss.php?version=2.0&amp;type=comments&amp;cid=11</wfw:commentRss>
    

    <author>nospam@example.com (Daniel Fischer)</author>
    <content:encoded>
    This is a piece of code from a project that runs on both the x86 and x86_64 architectures:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;font-size:9pt;&quot;&gt;&lt;span style=&quot;color:#808080&quot;&gt; 1 &lt;/span&gt;&lt;span style=&quot;color:#8f0055&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color:#8f0055&quot;&gt;inline&lt;/span&gt; &lt;span style=&quot;color:#8f0055&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color:#000000&quot;&gt;swap_int&lt;/span&gt;&lt;span style=&quot;color:#000000&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#8f0055&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color:#000000&quot;&gt;*&lt;/span&gt;a&lt;span style=&quot;color:#000000&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color:#8f0055&quot;&gt;int&lt;/span&gt; b&lt;span style=&quot;color:#000000&quot;&gt;) {&lt;/span&gt;
&lt;span style=&quot;color:#808080&quot;&gt; 2 &lt;/span&gt;    &lt;span style=&quot;color:#8f0055&quot;&gt;asm&lt;/span&gt; &lt;span style=&quot;color:#8f0055&quot;&gt;volatile&lt;/span&gt; &lt;span style=&quot;color:#000000&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#c00000&quot;&gt;&amp;quot;xchg %0, %1&amp;quot;&lt;/span&gt; &lt;span style=&quot;color:#000000&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color:#c00000&quot;&gt;&amp;quot;+r&amp;quot;&lt;/span&gt; &lt;span style=&quot;color:#000000&quot;&gt;(&lt;/span&gt;b&lt;span style=&quot;color:#000000&quot;&gt;) ,&lt;/span&gt; &lt;span style=&quot;color:#c00000&quot;&gt;&amp;quot;+m&amp;quot;&lt;/span&gt; &lt;span style=&quot;color:#000000&quot;&gt;(*&lt;/span&gt;a&lt;span style=&quot;color:#000000&quot;&gt;));&lt;/span&gt;
&lt;span style=&quot;color:#808080&quot;&gt; 3 &lt;/span&gt;    &lt;span style=&quot;color:#8f0055&quot;&gt;return&lt;/span&gt; b&lt;span style=&quot;color:#000000&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color:#808080&quot;&gt; 4 &lt;/span&gt;&lt;span style=&quot;color:#000000&quot;&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
It&#039;s fairly easy to see what it does: It swaps two values of type &lt;code&gt;int&lt;/code&gt;. This code works perfectly fine on both architectures, provided that you&#039;re using a compiler that understands the &lt;code&gt;asm&lt;/code&gt; statement, such as gcc. Later, this similar piece of code appears:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;font-size:9pt;&quot;&gt;&lt;span style=&quot;color:#808080&quot;&gt; 1 &lt;/span&gt;&lt;span style=&quot;color:#8f0055&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color:#8f0055&quot;&gt;inline&lt;/span&gt; &lt;span style=&quot;color:#8f0055&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color:#000000&quot;&gt;swap_char&lt;/span&gt;&lt;span style=&quot;color:#000000&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#8f0055&quot;&gt;char&lt;/span&gt; &lt;span style=&quot;color:#000000&quot;&gt;*&lt;/span&gt;a&lt;span style=&quot;color:#000000&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color:#8f0055&quot;&gt;char&lt;/span&gt; b&lt;span style=&quot;color:#000000&quot;&gt;) {&lt;/span&gt;
&lt;span style=&quot;color:#808080&quot;&gt; 2 &lt;/span&gt;    &lt;span style=&quot;color:#8f0055&quot;&gt;asm&lt;/span&gt; &lt;span style=&quot;color:#8f0055&quot;&gt;volatile&lt;/span&gt; &lt;span style=&quot;color:#000000&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#c00000&quot;&gt;&amp;quot;xchg %0, %1&amp;quot;&lt;/span&gt; &lt;span style=&quot;color:#000000&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color:#c00000&quot;&gt;&amp;quot;+r&amp;quot;&lt;/span&gt; &lt;span style=&quot;color:#000000&quot;&gt;(&lt;/span&gt;b&lt;span style=&quot;color:#000000&quot;&gt;) ,&lt;/span&gt; &lt;span style=&quot;color:#c00000&quot;&gt;&amp;quot;+m&amp;quot;&lt;/span&gt; &lt;span style=&quot;color:#000000&quot;&gt;(*&lt;/span&gt;a&lt;span style=&quot;color:#000000&quot;&gt;));&lt;/span&gt;
&lt;span style=&quot;color:#808080&quot;&gt; 3 &lt;/span&gt;    &lt;span style=&quot;color:#8f0055&quot;&gt;return&lt;/span&gt; b&lt;span style=&quot;color:#000000&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color:#808080&quot;&gt; 4 &lt;/span&gt;&lt;span style=&quot;color:#000000&quot;&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
This code still compiles and works just fine. For the most part. But when optimisation is turned on, you may get this error from gcc when building for x86:&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;&lt;code&gt;Error: bad register name `%dil&#039;&lt;/code&gt;&lt;/blockquote&gt;&lt;br /&gt;
&lt;br /&gt;
Then you try the same on x86_64 and the error is gone again. No wonder: As opposed to x86, the x86_64 architecture actually has the %dil register.&lt;br /&gt;
&lt;br /&gt;
At first, this appears to be a compiler bug. After all, the compiler is choosing a register that doesn&#039;t exist on x86. On closer look, it&#039;s a bug in the example code. The issue is that for the &lt;code&gt;b&lt;/code&gt; argument, the constraint &lt;code&gt;r&lt;/code&gt; is used, indicating that the value should be stored in any general-purpose register. In the first example, this is just fine. All of them will do for 32-bit operations. The second example, on closer examination, actually requires a register whose lower byte is accessible. On x86, there are only four general-purpose registers where this is true: EAX, EBX, ECX and EDX. On x86_64, this is also true for the ESI and EDI registers that are also treated as general-purpose registers on x86.&lt;br /&gt;
&lt;br /&gt;
So what happens is that the compiler correctly chooses the &lt;code&gt;%edi&lt;/code&gt; register, which satisfies the &lt;code&gt;r&lt;/code&gt; constraint. Later, the &lt;code&gt;xchg&lt;/code&gt; instruction is interpreted as referring to two byte-sized values due to the size of the arguments &lt;code&gt;*a&lt;/code&gt; and &lt;code&gt;b&lt;/code&gt;. Thus, the compiler translates the instruction to its 8-bit form and replaces the register placeholder &lt;code&gt;%0&lt;/code&gt; with the 8-bit form of the &lt;code&gt;%edi&lt;/code&gt; register, which is &lt;code&gt;%dil&lt;/code&gt;. During assembly, this fails because &lt;code&gt;%dil&lt;/code&gt; doesn&#039;t actually exist on x86.&lt;br /&gt;
&lt;br /&gt;
If there is a compiler bug, it is only that the error output is misleading. It shouldn&#039;t even try to use &lt;code&gt;%dil&lt;/code&gt;, it should warn about the real problem. &lt;br /&gt;
&lt;br /&gt;
The real bug is that in the example source, a byte-sized argument was qualified with a constraint that allowed any general-purpose register to be used, where instead, the set should be constrained to registers whose lower byte is available. In gcc, this can be achieved by using the &lt;code&gt;q&lt;/code&gt; constraint instead of &lt;code&gt;r&lt;/code&gt;. 
    </content:encoded>

    <pubDate>Fri, 29 May 2009 13:09:23 +0200</pubDate>
    <guid isPermaLink="false">http://portabilityblog.com/blog/archives/11-guid.html</guid>
    <category>32 bit</category>
<category>64 bit</category>
<category>gcc</category>
<category>x86</category>
<category>x86_64</category>

</item>
<item>
    <title>transparent_union</title>
    <link>http://portabilityblog.com/blog/archives/2-transparent_union.html</link>
            <category>Operating Systems</category>
    
    <comments>http://portabilityblog.com/blog/archives/2-transparent_union.html#comments</comments>
    <wfw:comment>http://portabilityblog.com/blog/wfwcomment.php?cid=2</wfw:comment>

    <slash:comments>4</slash:comments>
    <wfw:commentRss>http://portabilityblog.com/blog/rss.php?version=2.0&amp;type=comments&amp;cid=2</wfw:commentRss>
    

    <author>nospam@example.com (Daniel Fischer)</author>
    <content:encoded>
    Let&#039;s say you&#039;re writing a function that accepts a pointer to an int.&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;font-size:9pt;&quot;&gt;&lt;span style=&quot;color:#808080&quot;&gt; 1 &lt;/span&gt;&lt;span style=&quot;color:#8f0055&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color:#000000&quot;&gt;do_stuff_with_int&lt;/span&gt;&lt;span style=&quot;color:#000000&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#8f0055&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color:#000000&quot;&gt;*&lt;/span&gt;p&lt;span style=&quot;color:#000000&quot;&gt;) {&lt;/span&gt;
&lt;span style=&quot;color:#808080&quot;&gt; 2 &lt;/span&gt;  &lt;span style=&quot;color:#007f1c&quot;&gt;/* ... */&lt;/span&gt;
&lt;span style=&quot;color:#808080&quot;&gt; 3 &lt;/span&gt;&lt;span style=&quot;color:#000000&quot;&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
Later, you notice that the doing stuff operation doesn&#039;t depend on signedness at all, and decide that you want to use your function with unsigned int too. Just passing a pointer to an unsigned int will cause a warning. How would you get rid of it in a clean way? Easy, use a union.&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;font-size:9pt;&quot;&gt;&lt;span style=&quot;color:#808080&quot;&gt; 1 &lt;/span&gt;&lt;span style=&quot;color:#8f0055&quot;&gt;typedef&lt;/span&gt; &lt;span style=&quot;color:#8f0055&quot;&gt;union&lt;/span&gt; &lt;span style=&quot;color:#000000&quot;&gt;{&lt;/span&gt;
&lt;span style=&quot;color:#808080&quot;&gt; 2 &lt;/span&gt;  &lt;span style=&quot;color:#8f0055&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color:#000000&quot;&gt;*&lt;/span&gt;si&lt;span style=&quot;color:#000000&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color:#808080&quot;&gt; 3 &lt;/span&gt;  &lt;span style=&quot;color:#8f0055&quot;&gt;unsigned int&lt;/span&gt; &lt;span style=&quot;color:#000000&quot;&gt;*&lt;/span&gt;ui&lt;span style=&quot;color:#000000&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color:#808080&quot;&gt; 4 &lt;/span&gt;&lt;span style=&quot;color:#000000&quot;&gt;}&lt;/span&gt; signed_or_unsigned_int_pointer&lt;span style=&quot;color:#000000&quot;&gt;;&lt;/span&gt;
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
Now you have a type that can both contain a pointer to an int, or a pointer to an unsigned int. Wouldn&#039;t it be convenient if you could use your shiny new type to indicate that do_stuff_with_int() really can accept both types? That&#039;s where gcc&#039;s transparent_union attribute comes in. (Some other compilers also support this.)&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;font-size:9pt;&quot;&gt;&lt;span style=&quot;color:#808080&quot;&gt; 1 &lt;/span&gt;&lt;span style=&quot;color:#8f0055&quot;&gt;typedef&lt;/span&gt; &lt;span style=&quot;color:#8f0055&quot;&gt;union&lt;/span&gt; &lt;span style=&quot;color:#000000&quot;&gt;{&lt;/span&gt;
&lt;span style=&quot;color:#808080&quot;&gt; 2 &lt;/span&gt;  &lt;span style=&quot;color:#8f0055&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color:#000000&quot;&gt;*&lt;/span&gt;si&lt;span style=&quot;color:#000000&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color:#808080&quot;&gt; 3 &lt;/span&gt;  &lt;span style=&quot;color:#8f0055&quot;&gt;unsigned int&lt;/span&gt; &lt;span style=&quot;color:#000000&quot;&gt;*&lt;/span&gt;ui&lt;span style=&quot;color:#000000&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color:#808080&quot;&gt; 4 &lt;/span&gt;&lt;span style=&quot;color:#000000&quot;&gt;}&lt;/span&gt; signed_or_unsigned_int_pointer
&lt;span style=&quot;color:#808080&quot;&gt; 5 &lt;/span&gt;&lt;span style=&quot;color:#000000&quot;&gt;__attribute__&lt;/span&gt;&lt;span style=&quot;color:#000000&quot;&gt;((&lt;/span&gt;transparent_union&lt;span style=&quot;color:#000000&quot;&gt;));&lt;/span&gt;
&lt;span style=&quot;color:#808080&quot;&gt; 6 &lt;/span&gt;
&lt;span style=&quot;color:#808080&quot;&gt; 7 &lt;/span&gt;&lt;span style=&quot;color:#8f0055&quot;&gt;void&lt;/span&gt; &lt;span style=&quot;color:#000000&quot;&gt;do_stuff_with_int&lt;/span&gt;&lt;span style=&quot;color:#000000&quot;&gt;(&lt;/span&gt;signed_or_unsigned_int_pointer p&lt;span style=&quot;color:#000000&quot;&gt;) {&lt;/span&gt;
&lt;span style=&quot;color:#808080&quot;&gt; 8 &lt;/span&gt;  &lt;span style=&quot;color:#007f1c&quot;&gt;/* ... */&lt;/span&gt;
&lt;span style=&quot;color:#808080&quot;&gt; 9 &lt;/span&gt;&lt;span style=&quot;color:#000000&quot;&gt;}&lt;/span&gt;
&lt;span style=&quot;color:#808080&quot;&gt;10 &lt;/span&gt;
&lt;span style=&quot;color:#808080&quot;&gt;11 &lt;/span&gt;&lt;span style=&quot;color:#8f0055&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color:#000000&quot;&gt;main&lt;/span&gt;&lt;span style=&quot;color:#000000&quot;&gt;() {&lt;/span&gt;
&lt;span style=&quot;color:#808080&quot;&gt;12 &lt;/span&gt;  &lt;span style=&quot;color:#8f0055&quot;&gt;int&lt;/span&gt; a &lt;span style=&quot;color:#000000&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color:#2300ff&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#000000&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color:#808080&quot;&gt;13 &lt;/span&gt;  &lt;span style=&quot;color:#8f0055&quot;&gt;unsigned int&lt;/span&gt; b &lt;span style=&quot;color:#000000&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color:#2300ff&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#000000&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color:#808080&quot;&gt;14 &lt;/span&gt;
&lt;span style=&quot;color:#808080&quot;&gt;15 &lt;/span&gt;  &lt;span style=&quot;color:#000000&quot;&gt;do_stuff_with_int&lt;/span&gt;&lt;span style=&quot;color:#000000&quot;&gt;(&amp;amp;&lt;/span&gt;a&lt;span style=&quot;color:#000000&quot;&gt;);&lt;/span&gt;
&lt;span style=&quot;color:#808080&quot;&gt;16 &lt;/span&gt;  &lt;span style=&quot;color:#000000&quot;&gt;do_stuff_with_int&lt;/span&gt;&lt;span style=&quot;color:#000000&quot;&gt;(&amp;amp;&lt;/span&gt;b&lt;span style=&quot;color:#000000&quot;&gt;);&lt;/span&gt;
&lt;span style=&quot;color:#808080&quot;&gt;17 &lt;/span&gt;
&lt;span style=&quot;color:#808080&quot;&gt;18 &lt;/span&gt;  &lt;span style=&quot;color:#8f0055&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color:#2300ff&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#000000&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color:#808080&quot;&gt;19 &lt;/span&gt;&lt;span style=&quot;color:#000000&quot;&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
Now, what&#039;s the catch? You can only use transparent_union with unions that contain only types with the same representation. In other words, they need to be the same size. You can&#039;t, for example, use it with a 32-bit int and a 64-bit integer, in which case gcc will generate a warning. And lots of errors later on, because you&#039;re not passing unions to your function, but any one of their constituent types, which isn&#039;t allowed without transparent_union.&lt;br /&gt;
&lt;br /&gt;
And now, the reason why this post is related to portability:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;font-size:9pt;&quot;&gt;&lt;span style=&quot;color:#808080&quot;&gt; 1 &lt;/span&gt;&lt;span style=&quot;color:#8f0055&quot;&gt;typedef&lt;/span&gt; &lt;span style=&quot;color:#8f0055&quot;&gt;union&lt;/span&gt; &lt;span style=&quot;color:#000000&quot;&gt;{&lt;/span&gt;
&lt;span style=&quot;color:#808080&quot;&gt; 2 &lt;/span&gt;  &lt;span style=&quot;color:#8f0055&quot;&gt;int&lt;/span&gt; an_int&lt;span style=&quot;color:#000000&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color:#808080&quot;&gt; 3 &lt;/span&gt;  &lt;span style=&quot;color:#8f0055&quot;&gt;long&lt;/span&gt; a_long&lt;span style=&quot;color:#000000&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color:#808080&quot;&gt; 4 &lt;/span&gt;&lt;span style=&quot;color:#000000&quot;&gt;}&lt;/span&gt; int_union
&lt;span style=&quot;color:#808080&quot;&gt; 5 &lt;/span&gt;&lt;span style=&quot;color:#000000&quot;&gt;__attribute__&lt;/span&gt;&lt;span style=&quot;color:#000000&quot;&gt;((&lt;/span&gt;transparent_union&lt;span style=&quot;color:#000000&quot;&gt;));&lt;/span&gt;
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
The transparent_union attribute will be ignored on most 64 bit platforms.&lt;br /&gt;
&lt;br /&gt;
Treating int and long as the same type is a beginner&#039;s mistake. But what about this code?&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;font-size:9pt;&quot;&gt;&lt;span style=&quot;color:#808080&quot;&gt; 1 &lt;/span&gt;&lt;span style=&quot;color:#8f0055&quot;&gt;typedef&lt;/span&gt; &lt;span style=&quot;color:#8f0055&quot;&gt;union&lt;/span&gt; &lt;span style=&quot;color:#000000&quot;&gt;{&lt;/span&gt;
&lt;span style=&quot;color:#808080&quot;&gt; 2 &lt;/span&gt;  &lt;span style=&quot;color:#8f0055&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color:#8f0055&quot;&gt;volatile&lt;/span&gt; &lt;span style=&quot;color:#000000&quot;&gt;*&lt;/span&gt;i&lt;span style=&quot;color:#000000&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color:#808080&quot;&gt; 3 &lt;/span&gt;  &lt;span style=&quot;color:#8f0055&quot;&gt;unsigned int&lt;/span&gt; &lt;span style=&quot;color:#8f0055&quot;&gt;volatile&lt;/span&gt; &lt;span style=&quot;color:#000000&quot;&gt;*&lt;/span&gt;u&lt;span style=&quot;color:#000000&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color:#808080&quot;&gt; 4 &lt;/span&gt;&lt;span style=&quot;color:#000000&quot;&gt;}&lt;/span&gt; int_union
&lt;span style=&quot;color:#808080&quot;&gt; 5 &lt;/span&gt;&lt;span style=&quot;color:#000000&quot;&gt;__attribute__&lt;/span&gt;&lt;span style=&quot;color:#000000&quot;&gt;((&lt;/span&gt;transparent_union&lt;span style=&quot;color:#000000&quot;&gt;));&lt;/span&gt;
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
Should work, shouldn&#039;t it?&lt;br /&gt;
&lt;br /&gt;
Turns out it doesn&#039;t. That is, it works in most places. It even works on Mac OS X. Unless you build for the 64-bit PowerPC CPU. In that case, the attribute is ignored, even though the two types are still the same size. This only seems to happen on ppc64. On all three other architectures currently supported by Mac OS X, it works.&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;font-size:9pt;&quot;&gt;&lt;span style=&quot;color:#808080&quot;&gt; 1 &lt;/span&gt;$ gcc -c t.c -arch ppc
&lt;span style=&quot;color:#808080&quot;&gt; 2 &lt;/span&gt;$ gcc -c t.c -arch ppc64
&lt;span style=&quot;color:#808080&quot;&gt; 3 &lt;/span&gt;t.c:6: warning: &#039;transparent_union&#039; attribute ignored
&lt;span style=&quot;color:#808080&quot;&gt; 4 &lt;/span&gt;$ gcc -c t.c -arch i386 
&lt;span style=&quot;color:#808080&quot;&gt; 5 &lt;/span&gt;$ gcc -c t.c -arch x86_64&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
 
    </content:encoded>

    <pubDate>Sat, 15 Dec 2007 14:32:39 +0100</pubDate>
    <guid isPermaLink="false">http://portabilityblog.com/blog/archives/2-guid.html</guid>
    <category>gcc</category>
<category>mac os x</category>
<category>powerpc</category>

</item>

</channel>
</rss>