title: Packed bit fields in c structures - GCC
body: <p>I am working with structs in c on linux.
  I started using bit fields and the &quot;packed&quot; attribute and I came across a wierd behavior:</p>
  <pre><code>struct __attribute__((packed)) {
      int a:12;
      int b:32;
      int c:4;
  } t1;
  
  struct __attribute__((packed))  {
      int a:12;
      int b;
      int c:4;
  }t2;
  
  void main()
  {
      printf(&quot;%d\n&quot;,sizeof(t1)); //output - 6
      printf(&quot;%d\n&quot;,sizeof(t2)); //output - 7
  }
  </code></pre>
  <p>How come both structures  - that are exactly the same - take diffrent number of bytes?</p>