From bb58442054adbc502e54df0ce31516927da0b715 Mon Sep 17 00:00:00 2001 From: bwelling Date: Thu, 21 Feb 2019 13:45:11 -0800 Subject: [PATCH] Improve endian detection. (#5204) Add support for using __BYTE_ORDER__, to support platforms where g++ doesn't explicitly define __BIG_ENDIAN__, like Solaris Sparc. --- include/flatbuffers/base.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/flatbuffers/base.h b/include/flatbuffers/base.h index 295c7f67b..3e6afc69c 100644 --- a/include/flatbuffers/base.h +++ b/include/flatbuffers/base.h @@ -118,7 +118,8 @@ #endif // __s390x__ #if !defined(FLATBUFFERS_LITTLEENDIAN) #if defined(__GNUC__) || defined(__clang__) - #ifdef __BIG_ENDIAN__ + #if (defined(__BIG_ENDIAN__) || \ + (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)) #define FLATBUFFERS_LITTLEENDIAN 0 #else #define FLATBUFFERS_LITTLEENDIAN 1