Reputation: 18178
Whenever I need to define a file structure, I'm using compiler-specific commands (like #pragma pack(1)
) to ensure that I can safely read and write this file and don't need to worry about padding issues.
However, is there any other way to reach the same goal? I don't need to de-/serialize complex objects, just POD types.
Upvotes: 2
Views: 189
Reputation: 15768
It is impossible to define a cross-platform binary format that always nicely maps to the in-memory representation of types.
The two options for defining cross-platform file formats are:
Upvotes: 2
Reputation: 39370
Boost Serialization Library might be an option, if you want it to be solved fast and without much ado.
Upvotes: 0