From: Sebastian Pop Date: Tue, 11 Dec 2018 21:24:00 +0000 (-0600) Subject: check endianness of target architecture with preprocessor X-Git-Tag: 1.9.9-b1~592 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d2b1476776066143ce4bd9a1672c9f88baf83198;p=thirdparty%2Fzlib-ng.git check endianness of target architecture with preprocessor --- diff --git a/gzendian.h b/gzendian.h index 92da573ba..3b02f57b6 100644 --- a/gzendian.h +++ b/gzendian.h @@ -5,7 +5,16 @@ #ifndef ENDIAN_H_ #define ENDIAN_H_ -#ifdef __MINGW32__ +/* First check whether the compiler knows the target __BYTE_ORDER__. */ +#if defined(__BYTE_ORDER__) +# if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ +# define LITTLE_ENDIAN __ORDER_LITTLE_ENDIAN__ +# define BYTE_ORDER LITTLE_ENDIAN +# elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ +# define BIG_ENDIAN __ORDER_BIG_ENDIAN__ +# define BYTE_ORDER BIG_ENDIAN +# endif +#elif defined(__MINGW32__) # include #elif defined(WIN32) || defined(_WIN32) # define LITTLE_ENDIAN 1234