From f53204dd3c0ec0da8e61fbaf76aad9fb3e89ef72 Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Wed, 14 Aug 2024 15:37:18 +0200 Subject: [PATCH] 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. --- src/audio/utils.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/audio/utils.cpp b/src/audio/utils.cpp index 82054b938..6138f33b5 100644 --- a/src/audio/utils.cpp +++ b/src/audio/utils.cpp @@ -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;