Skip to content

Commit

Permalink
endian check from runtime to compile time
Browse files Browse the repository at this point in the history
Signed-off-by: Rosen Penev <[email protected]>
  • Loading branch information
neheb committed Jun 29, 2023
1 parent 3664f5b commit e4a4791
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit e4a4791

Please sign in to comment.