News for hackers. Stuff that matters.
Re:The Byte Order Fiasco by mfost on Saturday May 08, 2021 @10:32AM (#27087446)
I'd say, putting multiple of those types into a struct that then perfectly describes the memory layout of each byte of data in memory/network packet in a reliable and user friendly way to manipulate for the coder.
Re:The Byte Order Fiasco by foldr on Saturday May 08, 2021 @01:00PM (#27088856)
I see. That does seem helpful once you consider how these types compose, rather than thinking about a one-off conversion. However, I think it would be cleaner to have a library that auto-generated a parser for a given struct paired with an endianness specification, rather than baking the endianness into the types. (Probably this could be achieved by template metaprogramming too.)