title: Is the -mx32 GCC flag implemented (correctly)?
body: <p>I am trying to build a program that communicates with a 32-bit embedded system, that runs on a Linux based x86_64 machine (host). On the host program I have a structure containing a few pointers that reflects an identical structure on the embedded system.</p>
  
  <p>The problem is that on the host, pointers are natively 64-bits, so the offset of the structure members is not the same as in the embedded system. Thus, when copying the structure (as memcpy), the contents end up at the wrong place in the host copy.</p>
  
  <pre><code>struct {
      float a;
      float b;
      float *p;
      float *q;
  } mailbox;
  // sizeof(mailbox) is 4*4=16 on the embedded, but 2*4+2*8=24 on the host
  </code></pre>
  
  <p>Luckily, I found out <a href="http://gcc.gnu.org/onlinedocs/gcc/i386-and-x86_002d64-Options.html" rel="nofollow">here</a> that gcc has an option <code>-mx32</code> for generating 32-bit pointers on x86_64 machines. But, when trying to use this, I get an error saying:</p>
  
  <pre><code>$ gcc -mx32 test.c -o test.e
  cc1: error: unrecognized command line option "-mx32"
  </code></pre>
  
  <p>This is for gcc versions <em>4.4.3</em> and <em>4.7.0 20120120 (experimental)</em>.</p>
  
  <p><strong>Why doesn't this option work? Is there a way around this?</strong></p>
  
  <p>EDIT: Accrding to the <a href="http://gcc.gnu.org/onlinedocs/gcc-4.4.7/gcc/i386-and-x86_002d64-Options.html" rel="nofollow">v4.4.7 manual</a>, there was no -mx32 option available, and this is true up to <a href="http://gcc.gnu.org/onlinedocs/gcc-4.6.3/gcc/i386-and-x86_002d64-Options.html" rel="nofollow">v4.6.3</a>. OTOH, <a href="http://gcc.gnu.org/onlinedocs/gcc-4.7.0/gcc/i386-and-x86_002d64-Options.html" rel="nofollow">v4.7.0</a> does show that option, so it may be that the Jan-20 version I am using is not the final one?!</p>