(kemona_halftau)
why must the wii u use a big-endian cpu
(kemona_halftau)
@noisytoot true, but there are some valid reasons why some software/libraries assume little-endian for example casting a pointer to a 64-bit value into a pointer for a 32-bit value without needing to shift the address, or for just efficiently reading some file format or network protocol packet without doing byte-swapping (although tcp/ip uses big-endian values)
@kemona_halftau true for the first part (I don’t know what to suggest other than not writing code that does that if you want it to be portable), but you can efficiently read and write data in a fixed endianness without writing endianness-specific code or doing unnecessary byte-swaps:
uint16_t load_u16le(const uint16_t *p) {
const uint8_t *b = (uint8_t *) p;
return b[0] | (((uint16_t)b[1]) << 8);
}
compilers know what this is and will optimize it away on little-endian systems
(kemona_halftau)
@noisytoot i did not know that! wow, compilers are smart!!