title: Why bit endianness is an issue in bitfields?
body: <p>Any portable code that uses bitfields seems to distinguish between little- and big-endian platforms. See the <a href="http://lxr.linux.no/#linux+v2.6.38/include/linux/ip.h">declaration of struct iphdr in linux kernel</a> for an example of such code. I fail to understand why bit endianness is an issue at all.</p>
  
  <p>As far as I understand, bitfields are purely compiler constructs, used to facilitate bit level manipulations.</p>
  
  <p>For instance, consider the following bitfield:
  <code><pre>
  struct ParsedInt {
      unsigned int f1:1;
      unsigned int f2:3;
      unsigned int f3:4;
  };
  uint8_t i;
  struct ParsedInt *d = &i;
  </pre></code>
  Here, writing <code>d->f2</code> is simply a compact and readable way of saying <code>(i>>1) &amp;  (1&lt;&lt;4 - 1)</code>.</p>
  
  <p>However, bit operations are well-defined and work regardless of the architecture. So, how come bitfields are not portable?</p>