Skip to content

Commit e4a4791

Browse files
committed
endian check from runtime to compile time
Signed-off-by: Rosen Penev <[email protected]>
1 parent 3664f5b commit e4a4791

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/image.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,20 @@ bool Image::isPrintICC(uint16_t type, Exiv2::PrintStructureOption option) {
168168
}
169169

170170
bool Image::isBigEndianPlatform() {
171+
#if defined(__BYTE_ORDER)
172+
#if __BYTE_ORDER == __BIG_ENDIAN
173+
return true;
174+
#else
175+
return false;
176+
#endif
177+
#else
171178
union {
172179
uint32_t i;
173180
char c[4];
174181
} e = {0x01000000};
175182

176183
return e.c[0] != 0;
184+
#endif
177185
}
178186
bool Image::isLittleEndianPlatform() {
179187
return !isBigEndianPlatform();

0 commit comments

Comments
 (0)