I have a C ++ application with the underlying structure written to a file. Now I need to unmount them using python. The main problem is how to reflect a parameter pragma packin python.
C ++ structure
#pragma pack(1)
struct abc
{
unsigned char r1;
unsigned char r2;
unsigned char p1;
unsigned int id;
};
#pragma pack()
Now the size of the structure 7 not 8, this data is written to the data file. How to get this data using python.
Note:
1. I am using ctypes, and the above structure is a sampling structure.
ctypes uses its own byte order for structures and unions. To build structures with non-local byte order, you can use one of the base classes BigEndianStructure, LittleEndianStructure, BigEndianUnion and LittleEndianUnion. These classes cannot contain pointer fields.
python .