I'm working on rather old code atm, and this code tests the endianness of types like short
, int
, long
and long long
separately.
Are there systems "still in use" that actually have different endianness for different types (due to different sizes of these types)? The only example that I know of is the PDP-11, where the two 16 bit halves of 32 bit values are stored in "big endian order" whereas the two 8 bit halves of each of these 16 bit are stored in "little endian order".
Due to undefined behavior in the mentioned tests I probably need to rewrite parts of this and want to know if it's worth the effort to keep that complexity. I know that (and how) I can write code that's independent of the system endianness, but this would be a lot of changes that I currently don't have the time for.
long
was. Personally, I would not worry about mixed-endianness unless there was a current system that the code runs on that has it. You might well need to worry about big-endian vs little-endian, though there are usually ways to treat that systematically via serialization functions. – Pinguidfloat
anddouble
were big-endian whereint
etc were little-endian. (I vaguely remember that this was because the coprocessor was a nearly-unmodified MC68881, designed to work with the 68020 series, which were big-endian throughout.) By "more recent", mind, I mean the early 1990s. Modern ARM, with built-in FPU, uses consistent endianness for everything. – Silma