command.cpp (477B)
1 #include "command.h" 2 3 namespace bridgeLib 4 { 5 enum class HostEndian 6 { 7 Big, 8 Little 9 }; 10 11 constexpr HostEndian hostEndian() 12 { 13 constexpr uint32_t test32 = 0x01020304; 14 constexpr uint8_t test8 = static_cast<const uint8_t&>(test32); 15 16 static_assert(test8 == 0x01 || test8 == 0x04, "unable to determine endianess"); 17 18 return test8 == 0x01 ? HostEndian::Big : HostEndian::Little; 19 } 20 21 static_assert(hostEndian() == HostEndian::Little, "big endian systems not supported"); 22 }