title: struct/class bit field packing
body: <p>I'd like to use the bit field feature of cpp.<br/>
  However i get all kind of strange behivours and i was wondering if there is <br/>
  a way to constrain the compiler.<br/></p>
  
  <p>I'd like to use this bit field:<br/></p>
  
  <pre><code>class MyBitField
  {
     uint32 a :  8;
     uint32 b : 32;
     uint32 c : 32;
  }
  </code></pre>
  
  <p>Now using this code:<br/></p>
  
  <pre><code>uint8 rawData[9] = {0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xFF, 0xFF};
  MyBitField \*pMyBitField = (MyBitField\*)rawData;
  </code></pre>
  
  <p>I expect(on little endian 32bit CPU): <br/>
  the a's field of the pMyBitField  to be 0x12,<br/>
  the b's field of the pMyBitField  to be 0x9A785634,<br/>
  the a's field of the pMyBitField  to be 0xFFFFDEBC.<br/></p>
  
  <p>The compiler choose to make some unexplained alignment.<br/>
  I know that in case you use different types inside the bit filed you might get alignment, but this is not the case.<br/>
  How can i do it?<br/></p>
  
  <p>Let's focused on Visual Studio 2005 but any other env support will be blessed as well.<br/></p>
  
  <p>*I read some post of packing but it did not change the alignment problem.<br/></p>
  
  <p>Thanks!<br/></p>