title: Struct Bit Packing and LSB / MSB ambiguity C++
body: <p>I had to write a c++ code for the following packet header:</p>
  
  <p><img src="https://i.stack.imgur.com/9iHLr.jpg" alt=""></p>
  
  <p><a href="https://dl.dropboxusercontent.com/u/4740547/TF%20Primary%20Header.png" rel="nofollow noreferrer">Original image link, PNG version of the above JPEG.</a></p>
  
  <p>Here is the struct code I wrote for the above Packet Format. I want to know if the uint8_t or the uint16_t bit fields are correct</p>
  
  <pre><code>    struct TelemetryTransferFramePrimaryHeader
      {
          //-- 6 Ocets Long --//
  
          //-- Master Channel ID (2 octets)--//
          uint16_t TransferFrameVersionNumber : 2;
          uint16_t SpacecraftID : 10;
          uint16_t VirtualChannelID : 3;
          uint16_t OCFFlag : 1;
  
          //-----------------//
  
          uint8_t MasterChannelFrameCount;
          uint8_t VirtualChannelFrameCount;
  
          //-- Transfer Frame Data Field Status (2 octets) --//
  
          uint16_t TransferFrameSecondaryHeaderFlag : 1;
          uint16_t SyncFlag : 1;
          uint16_t PacketOrderFlag : 1;
          uint16_t SegmentLengthID : 2;
          uint16_t FirstHeaderPointer : 11;
  
          //-----------------//
  
      };
  </code></pre>
  
  <p>How do I ensure that that the LSB -> MSB is preserved in the struct ?</p>
  
  <p>I keep getting confused, and I've tried reading up but it ends up confusing me even more.</p>
  
  <p>PS: I am using a 32bit processor. </p>