Skip to content

Commit

Permalink
Improve compile-time detection of host endianness.
Browse files Browse the repository at this point in the history
Should fix issue #86.
  • Loading branch information
mmp committed Sep 7, 2016
1 parent 867a2c4 commit 61b5039
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/core/imageio.cpp
Expand Up @@ -287,15 +287,25 @@ static RGBSpectrum *ReadImagePNG(const std::string &name, int *width,
*/

static bool hostLittleEndian =
#if defined(__LITTLE_ENDIAN__) || defined(__i386__) || defined(__x86_64__) || \
defined(WIN32)
#if defined(__BYTE_ORDER__)
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
true
#elif defined(__BIG_ENDIAN__)
false
#elif defined(__sparc) || defined(__sparc__)
#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
false
#else
#error "__BYTE_ORDER__ defined but has unexpected value"
#endif
#else
#error "Can't detect machine endian-ness at compile-time."
#if defined(__LITTLE_ENDIAN__) || defined(__i386__) || defined(__x86_64__) || \
defined(WIN32)
true
#elif defined(__BIG_ENDIAN__)
false
#elif defined(__sparc) || defined(__sparc__)
false
#else
#error "Can't detect machine endian-ness at compile-time."
#endif
#endif
;

Expand Down

0 comments on commit 61b5039

Please sign in to comment.