"brian m. carlson" <sandals@xxxxxxxxxxxxxxxxxxxx> writes: > One additional option you can add if you want (it's completely optional) > is that if `__STDC_VERSION__` is 202311L or larger, then you can > `#include <stdbit.h>`, which has `__STDC_ENDIAN_LITTLE__`, > `__STDC_ENDIAN_BIG__`, and `__STDC_ENDIAN_NATIVE__`. > > That will work on a modern GCC or clang with an appropriate compiler > flag. I don't know about MSVC, but it might be an option for people who > want to use more esoteric compilers which support standards but aren't > very compatible with GCC and clang. Another standard that is too new to be common, but POSIX.1-2024 added <endian.h> with BYTE_ORDER, LITTLE_ENDIAN, and BIG_ENDIAN [1]. In practice, some systems will have it because glibc had it for a long time. Collin [1] https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/endian.h.html