Ensure the endian test is constexpr
This commit is contained in:
+6
-5
@@ -4,11 +4,12 @@
|
|||||||
#if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__)
|
#if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__)
|
||||||
#define IS_LITTLE_ENDIAN (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
|
#define IS_LITTLE_ENDIAN (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
|
||||||
#else
|
#else
|
||||||
static const union {
|
constexpr inline bool EndianTest() noexcept
|
||||||
unsigned int u;
|
{
|
||||||
unsigned char b[sizeof(unsigned int)];
|
constexpr int test_val{1};
|
||||||
} EndianTest = { 1 };
|
return static_cast<const char&>(test_val);
|
||||||
#define IS_LITTLE_ENDIAN (EndianTest.b[0] == 1)
|
}
|
||||||
|
#define IS_LITTLE_ENDIAN (EndianTest())
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* AL_ENDIANTEST_H */
|
#endif /* AL_ENDIANTEST_H */
|
||||||
|
|||||||
Reference in New Issue
Block a user