Improve endian detection. (#5204)

Add support for using __BYTE_ORDER__, to support platforms where g++
doesn't explicitly define __BIG_ENDIAN__, like Solaris Sparc.
This commit is contained in:
bwelling 2019-02-21 13:45:11 -08:00 committed by Wouter van Oortmerssen
parent 4567b13115
commit bb58442054
1 changed files with 2 additions and 1 deletions

View File

@ -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