--- rxvt-unicode/src/rxvtutil.h 2010/12/18 18:17:39 1.41 +++ rxvt-unicode/src/rxvtutil.h 2011/01/03 03:05:47 1.42 @@ -3,6 +3,7 @@ #include #include +#include using namespace std; @@ -42,16 +43,18 @@ # define THROW(x) throw x #endif -extern class byteorder { - static unsigned int e; // at least 32 bits -public: - byteorder (); - - static bool big_endian () { return e == 0x11223344; }; - static bool network () { return e == 0x11223344; }; - static bool little_endian () { return e == 0x44332211; }; - static bool vax () { return e == 0x44332211; }; -} byteorder; +namespace byteorder { + static uint32_t e () + { + char c [4] = { 0x11, 0x22, 0x33, 0x44 }; + return *(uint32_t *)c; + } + + static bool big_endian () { return e () == 0x11223344; }; + static bool network () { return big_endian (); }; + static bool little_endian () { return e () == 0x44332211; }; + static bool vax () { return little_endian (); }; +}; // various utility functions template static inline T min (T a, U b) { return a < (T)b ? a : (T)b; }