I have a structure with the following format:
struct Serializable { uint64_t value1; uint32_t value2; uint16_t value3; uint8_t value4;
Member implementation of size() :
uint64_t Serializable::size() { return sizeof(uint64_t) + sizeof(uint32_t) + sizeof(uint16_t) + sizeof(uint8_t); }
If I write an object of the specified structure to a file using fstream , as indicated in the following code:
std::fstream fWrite ("dump.dat", std::ios_base::out | std::ios_base::binary);
Will the content written to dump.dat be cross-platform?
Assuming I'm writing a different class and structure comparable to working with Visual C ++, then Will the Windows-side application interpret the dump.dat file in the same way as the Linux side?
If not, can you explain what other factors should be considered besides filling and differences in Endianness (which depend on the processor architecture) to make this cross-platform?
I understand that there are too many serialization libraries that are well tested and widely used. But I do this solely for training.
source share