Skip to content

Commit

Permalink
add std::endian support if available
Browse files Browse the repository at this point in the history
Signed-off-by: Rosen Penev <rosenp@gmail.com>
  • Loading branch information
neheb committed Jul 20, 2023
1 parent a2d6996 commit 32c05d4
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@

// + standard includes
#include <array>
#include <bit>
#include <cstdio>
#include <cstring>
#include <limits>
Expand Down Expand Up @@ -168,7 +169,9 @@ bool Image::isPrintICC(uint16_t type, Exiv2::PrintStructureOption option) {
}

bool Image::isBigEndianPlatform() {
#ifdef __LITTLE_ENDIAN__
#ifdef __cpp_lib_endian
return std::endian::native == std::endian::big;
#elif defined(__LITTLE_ENDIAN__)
return false;
#elif defined(__BIG_ENDIAN__)
return true;
Expand All @@ -188,7 +191,9 @@ bool Image::isBigEndianPlatform() {
#endif
}
bool Image::isLittleEndianPlatform() {
#ifdef __LITTLE_ENDIAN__
#ifdef __cpp_lib_endian
return std::endian::native == std::endian::little;
#elif defined(__LITTLE_ENDIAN__)
return true;
#else
return !isBigEndianPlatform();
Expand Down

0 comments on commit 32c05d4

Please sign in to comment.