Fix serialization on non-32-bit, big-endian systems (#159)

This commit is contained in:
Dan Rose 2020-04-17 16:54:06 -05:00 committed by GitHub
parent 073d21ab8f
commit 5616437a4d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -299,8 +299,9 @@ protected:
void serialize_u32(CDRCursor * cursor, size_t value) const void serialize_u32(CDRCursor * cursor, size_t value) const
{ {
assert(value <= std::numeric_limits<uint32_t>::max()); assert(value <= std::numeric_limits<uint32_t>::max());
auto u32_value = static_cast<uint32_t>(value);
cursor->align(4); cursor->align(4);
cursor->put_bytes(&value, 4); cursor->put_bytes(&u32_value, 4);
} }
static size_t get_cdr_size_of_primitive(ROSIDL_TypeKind tk) static size_t get_cdr_size_of_primitive(ROSIDL_TypeKind tk)