by LegionMammal978 · 2y ago · 0 comments
But if you know you're not going to have endianness problems, you can just skip that step entirely.
For complicated data structures, it's probably best to use a library that serializes to a common standard. (For example, protocol buffers or JSON.)
But I think the article assumes you don't get to choose the protocol, so it probably has to be hand-written by someone.
Struct layouts for FFI in other languages tend to follow the C convention and/or allow explicit field offsets to be specified. Regardless, if you use the proper language constructs, it's nowhere near as undefined as "whatever the compiler happens to generate".
[0] https://www.gnu.org/software/c-intro-and-ref/manual/html_nod...