Skip to content

Commit b832728

Browse files
committed
add std::endian support if available
Signed-off-by: Rosen Penev <[email protected]>
1 parent 9894c69 commit b832728

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/image.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@
5151
#include <limits>
5252
#include <set>
5353

54+
#ifdef __cpp_lib_endian
55+
#include <bit>
56+
#endif
57+
5458
// *****************************************************************************
5559
namespace {
5660
using namespace Exiv2;
@@ -168,7 +172,9 @@ bool Image::isPrintICC(uint16_t type, Exiv2::PrintStructureOption option) {
168172
}
169173

170174
bool Image::isBigEndianPlatform() {
171-
#ifdef __LITTLE_ENDIAN__
175+
#ifdef __cpp_lib_endian
176+
return std::endian::native == std::endian::big;
177+
#elif defined(__LITTLE_ENDIAN__)
172178
return false;
173179
#elif defined(__BIG_ENDIAN__)
174180
return true;
@@ -188,7 +194,9 @@ bool Image::isBigEndianPlatform() {
188194
#endif
189195
}
190196
bool Image::isLittleEndianPlatform() {
191-
#ifdef __LITTLE_ENDIAN__
197+
#ifdef __cpp_lib_endian
198+
return std::endian::native == std::endian::little;
199+
#elif defined(__LITTLE_ENDIAN__)
192200
return true;
193201
#else
194202
return !isBigEndianPlatform();

0 commit comments

Comments
 (0)