From 870ea3acfd9a39c16b6c851a398b0df1253fd924 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Thu, 29 Jun 2023 13:18:00 -0700 Subject: [PATCH] endian check from runtime to compile time Signed-off-by: Rosen Penev --- src/image.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/image.cpp b/src/image.cpp index 05d8345f9d..bc18d3c7c9 100644 --- a/src/image.cpp +++ b/src/image.cpp @@ -168,12 +168,20 @@ bool Image::isPrintICC(uint16_t type, Exiv2::PrintStructureOption option) { } bool Image::isBigEndianPlatform() { +#if defined(__BYTE_ORDER) +#if __BYTE_ORDER == __BIG_ENDIAN + return true; +#else + return false; +#endif +#else union { uint32_t i; char c[4]; } e = {0x01000000}; return e.c[0] != 0; +#endif } bool Image::isLittleEndianPlatform() { return !isBigEndianPlatform();