Re:A review of endianness bugs in Qt, and how they were fixed
by sgerenser on Saturday January 02, 2021 @02:30PM
(#25615646)
The snippet assumes the data being read is little endian, yes. You can make a different snippet if you want to read big endian. You use an equivalent snippet for the writing side, and boom. You never need any #ifdefs in those functions. Is it actually better than using functions like you describe? Maybe. A part of me does love the elegance of using the exact same code on any platform regardless of the native byte order. This construct was suggested/encouraged by Rob Pike: https://commandcenter.blogspot.com/2012/04/byte-order-fallac...
[ Parent
| on HN ]
There are no comments on this comment yet.