title: What is zero-width bit field
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/4297095/practical-use-of-zero-length-bitfields">Practical Use of Zero-Length Bitfields</a>  </p>
  </blockquote>
  
  
  
  <p>Why some structures have zero-width bit fields, and why is it required?</p>
  
  <pre><code>struct foo {
    int    a:3;
    int    b:2;
    int     :0; // Force alignment to next boundary.
    int    c:4;
    int    d:3;
  };
  
  int main()
  {
          int i = 0xFFFF;
          struct foo *f = (struct foo *)&amp;i;
          printf("a=%d\nb=%d\nc=%d\nd=%d\n", f-&gt;a, f-&gt;b, f-&gt;c, f-&gt;d);
          return 0;
  }
  </code></pre>
  
  <p>The output of above program is</p>
  
  <pre><code>manav@os-team:~/programs/test$ ./a.out
  a=-1
  b=-1
  c=-8
  d=0
  </code></pre>
  
  <p>Please explain why these values are negative, and the memory layout of these variables inside the structure?</p>