audio/utils: use static_assert for endianness

Use static_assert to ensure little endian instead of the preprocessor
checks - if the those macros are not defined by the compiler, the check
will be eliminated. If other complier is used, write this more
generically.
This commit is contained in:
Martin Pulec
2024-08-14 15:37:18 +02:00
parent 50812bba34
commit f53204dd3c

View File

@@ -56,9 +56,8 @@
#include "utils/macros.h"
#include "utils/misc.h"
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
#error "This code will not run with a big-endian machine. Please report a bug if you reach here."
#endif // __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
static_assert(__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__,
"The code below assumes little endianness.");
using std::clamp;
using std::max;