3 ms·
Ie how do you know the target's endianness? C++20 added std::endian. Otherwise you can use a macro like this one from SDL https://github.com/libsdl-org/SDL/blo
by edflsafoiewq 5y ago
Ie how do you know the target's endianness? C++20 added std::endian. Otherwise you can use a macro like this one from SDL
https://github.com/libsdl-org/SDL/blob/9dc97afa7190aca5bdf923ed13d723197c083547/include/SDL_endian.h#L61-L82 https://github.com/libsdl-org/SDL/blob/9dc97afa7190aca5bdf92...
- hermitdev 5y agoThere have been CPU architectures where the endianness at compile time isn't necessarily sufficient. I forget which, maybe it was DEC Alpha, where the CPU could flip back and forth? I can't recall if it was a "choose at boot" or a per process change.
- magicalhippo 5y agoARM allows dynamic changing of endianess[1]. [1]: https://developer.arm.com/documentation/dui0489/h/arm-and-thumb-instructions/setend https://developer.arm.com/documentation/dui0489/h/arm-and-th...
- account42 5y agoWhich nothing will be able to deal with so you might as well not bother to support it. Your compiler will also assume a fixed endianness based on the target triple.