Fix compilation on big endian systems

This commit is contained in:
badaix 2021-10-16 21:53:26 +02:00
parent 5513d94285
commit b4b9eb83ce

View file

@ -242,7 +242,7 @@ protected:
void writeVal(std::ostream& stream, const message_type& val) const void writeVal(std::ostream& stream, const message_type& val) const
{ {
uint16_t v = static_cast<uint16_t>(SWAP_16(val)); uint16_t v = static_cast<uint16_t>(SWAP_16(static_cast<uint16_t>(val)));
stream.write(reinterpret_cast<const char*>(&v), sizeof(uint16_t)); stream.write(reinterpret_cast<const char*>(&v), sizeof(uint16_t));
} }
@ -299,7 +299,7 @@ protected:
void readVal(std::istream& stream, message_type& val) const void readVal(std::istream& stream, message_type& val) const
{ {
stream.read(reinterpret_cast<char*>(&val), sizeof(uint16_t)); stream.read(reinterpret_cast<char*>(&val), sizeof(uint16_t));
val = static_cast<message_type>(SWAP_16(val)); val = static_cast<message_type>(SWAP_16(static_cast<uint16_t>(val)));
} }
void readVal(std::istream& stream, int16_t& val) const void readVal(std::istream& stream, int16_t& val) const