There are 0010 0000 kinds of people in the world: Those that understand the difference between Big Endian and Little Endian, and those that do not.
My own endianness experience falls into roughly three categories: sharing binary data between heterogeneous processors, in protocols (most famous: TCP/IP) and in TDD unit testing C code. The last one is what prompted this blog post.
Solutions? For more readable, portable code, I’m avoiding macro based solutions. There is a tools based approach: Detecting Endian Issues with Static Analysis Tools. Sometimes, I’ll get lucky and the processor is able to handle both such as some DSPs.
One method for TDD for embedded systems tests the same source code on both the development platform and the target platform. For my personal embedded project, each platform had different endianness. I used a wrapper function whose implementation was determined by the compiler preprocessor. On the host platform (Intel Linux) I used byte-by-byte operations. On the target platform, I used intrinsic functions to operate on multiple byte-sized data.
This problem should be addressed at the architecture and protocol level and highlights the importance of test vectors which will show errors when the endianess is wrong.