title: How to enforce the struct bit order with the GCC compiler?
body: <p>I was wondering if there is a GCC C Compiler directive that allows me to determine the bit order for packing of a structure? Something to the likes of:</p>
  
  <pre><code>#pragma bit_order left
  </code></pre>
  
  <p>The rationale for such a need is that I have the following structure:</p>
  
  <pre><code>struct {
         union {
               unsigned char BYTE;
               struct {
                   unsigned char B0: 1;
                   unsigned char B1: 1;
                   unsigned char B2: 1;
                   unsigned char B3: 1;
                   unsigned char B4: 4;
               }BIT;
         }ITEM;
  } myStruct;
  </code></pre>
  
  <p>With this structure, I would like the compiler to pack it this way:</p>
  
  <pre><code>Bit order: | 7  6  5  4  3  2  1  0 |
  Label:     |B0 B1 B2 B3 B4 B5 B6 B7 |
  </code></pre>
  
  <p>Rather than how GCC does it:</p>
  
  <pre><code>Bit order: | 7  6  5  4  3  2  1  0 |
  Label:     |B7 B6 B5 B4 B3 B2 B1 B0 |
  </code></pre>
  
  <p>I am dealing with MCUs that have huge header files that have structures that compute bit offsets according to stipulated hardware addresses. I am hoping that there is a compiler directive in GCC C Compiler that does the bit order swap for me before I attempt the flip all the fields in the manufacturer supplied file.</p>