removed test for unsigned long in serialization, and added back pragma to avoid strict aliasing error in rstypes.h

This commit is contained in:
csoler 2019-01-25 14:23:08 +01:00
parent 3836ed836b
commit ad45a7781c
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C
2 changed files with 7 additions and 2 deletions

View File

@ -278,6 +278,9 @@ struct DirStub : RsSerializable
RS_SERIAL_PROCESS(type);
RS_SERIAL_PROCESS(name);
#if defined(__GNUC__) && !defined(__clang__)
# pragma GCC diagnostic ignored "-Wstrict-aliasing"
#endif // defined(__GNUC__) && !defined(__clang__)
// (Cyril) We have to do this because on some systems (MacOS) uintptr_t is unsigned long which is not well defined. It is always
// preferable to force type serialization to the correct size rather than letting the compiler choose for us.
// /!\ This structure cannot be sent over the network. The serialization would be inconsistent.
@ -295,6 +298,9 @@ struct DirStub : RsSerializable
else
std::cerr << __PRETTY_FUNCTION__ << ": cannot serialize raw pointer of size " << sizeof(ref) << std::endl;
#if defined(__GNUC__) && !defined(__clang__)
# pragma GCC diagnostic pop
#endif // defined(__GNUC__) && !defined(__clang__)
}
};

View File

@ -131,8 +131,7 @@ struct RsTypeSerializer
/// Generic types
template<typename T>
typename std::enable_if<std::is_same<RsTlvItem,T>::value
|| !(std::is_base_of<RsSerializable,T>::value || std::is_enum<T>::value || std::is_base_of<RsTlvItem,T>::value || std::is_same<unsigned long,T>::value)>::type
typename std::enable_if<std::is_same<RsTlvItem,T>::value || !(std::is_base_of<RsSerializable,T>::value || std::is_enum<T>::value || std::is_base_of<RsTlvItem,T>::value )>::type
static /*void*/ serial_process( RsGenericSerializer::SerializeJob j,
RsGenericSerializer::SerializeContext& ctx,
T& member, const std::string& member_name )