4 ms·
This works when your serialization format is designed to be either big or little endian. But for some programs, the serialization format is memcpy the structure
by uluyol 4y ago
This works when your serialization format is designed to be either big or little endian. But for some programs, the serialization format is memcpy the structure to disk. This isn't a good strategy, but unfortunately it can be difficult to undo historical choices.
So the padding, alignment, endianness, all leak. And it sounds like X does something like this: clients expect the endianness of serialized data to match the local machine and the server can optionally account for this.
- asveikau 4y agoI've done things like this. First, the structs need the nonstandard pragmas and attributes to not pad. Then, all accesses of 16, 32, or 64 bit quantities need to go through a helper function. Even with that baggage, the syntax of having struct member access is can still feel more convenient than more verbose serialization code.