Skip to content

Commit

Permalink
audio/utils: use static_assert for endianness
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
MartinPulec committed Aug 14, 2024
1 parent 50812bb commit f53204d
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/audio/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit f53204d

Please sign in to comment.