mirror of
https://gitlab.com/obbart/universal_robots_ros_driver.git
synced 2026-04-10 10:00:48 +02:00
Fixed strict alisasing warnings and double/float big endian issues
This commit is contained in:
@@ -66,20 +66,14 @@ public:
|
||||
{
|
||||
return be64toh(val);
|
||||
}
|
||||
float decode(float val)
|
||||
{
|
||||
return be32toh(val);
|
||||
}
|
||||
double decode(double val)
|
||||
{
|
||||
return be64toh(val);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T peek()
|
||||
{
|
||||
assert(_buf_pos <= _buf_end);
|
||||
return decode(*(reinterpret_cast<T*>(_buf_pos)));
|
||||
T val;
|
||||
std::memcpy(&val, _buf_pos, sizeof(T));
|
||||
return decode(val);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@@ -89,6 +83,19 @@ public:
|
||||
_buf_pos += sizeof(T);
|
||||
}
|
||||
|
||||
void parse(double& val)
|
||||
{
|
||||
uint64_t inner;
|
||||
parse<uint64_t>(inner);
|
||||
std::memcpy(&val, &inner, sizeof(double));
|
||||
}
|
||||
void parse(float& val)
|
||||
{
|
||||
uint32_t inner;
|
||||
parse<uint32_t>(inner);
|
||||
std::memcpy(&val, &inner, sizeof(float));
|
||||
}
|
||||
|
||||
// UR uses 1 byte for boolean values but sizeof(bool) is implementation
|
||||
// defined so we must ensure they're parsed as uint8_t on all compilers
|
||||
void parse(bool& val)
|
||||
|
||||
Reference in New Issue
Block a user