title: python ctypes pragma pack for byte aligned read
body: <p>I have a C++ application with below structure written to file. Now I need to unmarshal them using python, The basic problem here is how to reflect the <code>pragma pack</code> option in python.  </p>
  
  <p>C++ Structure  </p>
  
  <pre><code>#pragma pack(1)
  struct abc  
  {  
  unsigned char r1;  
  unsigned char r2;  
  unsigned char p1;  
  unsigned int id;  
  };  
  #pragma pack()
  </code></pre>
  
  <p>Now, the structure size is <code>7 not 8</code>,this data is written into a data file. How do I retrieve this data using python.   </p>
  
  <p>Note :<br>
  1. I am using ctypes, and the above structure is a sample structure.  </p>
  
  <hr>
  
  <p><em>ctypes uses the native byte order for Structures and Unions. To build structures with non-native byte order, you can use one of the BigEndianStructure, LittleEndianStructure, BigEndianUnion, and LittleEndianUnion base classes. These classes cannot contain pointer fields</em></p>
  
  <hr>
  
  <p>The above information from python docs, does not delve into details.</p>