From 7930039ef15cd6a406abcaba623bad8e6f8ec510 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Milo=C5=A1=20Komar=C4=8Devi=C4=87?= Date: Tue, 11 Jul 2023 15:33:26 +0200 Subject: [PATCH] Use compiler macros for endianness --- src/image.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/image.cpp b/src/image.cpp index bc18d3c7c9..bfe1e1a53b 100644 --- a/src/image.cpp +++ b/src/image.cpp @@ -168,8 +168,12 @@ bool Image::isPrintICC(uint16_t type, Exiv2::PrintStructureOption option) { } bool Image::isBigEndianPlatform() { -#if defined(__BYTE_ORDER) -#if __BYTE_ORDER == __BIG_ENDIAN +#ifdef __LITTLE_ENDIAN__ + return false; +#elif defined(__BIG_ENDIAN__) + return true; +#elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) +#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ return true; #else return false; @@ -184,7 +188,11 @@ bool Image::isBigEndianPlatform() { #endif } bool Image::isLittleEndianPlatform() { +#ifdef __LITTLE_ENDIAN__ + return true; +#else return !isBigEndianPlatform(); +#endif } uint64_t Image::byteSwap(uint64_t value, bool bSwap) {