mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-07-27 00:15:51 -04:00
fixed template problem in memory handle serialization
This commit is contained in:
parent
64b584cccc
commit
3836ed836b
1 changed files with 18 additions and 8 deletions
|
@ -277,14 +277,24 @@ struct DirStub : RsSerializable
|
||||||
{
|
{
|
||||||
RS_SERIAL_PROCESS(type);
|
RS_SERIAL_PROCESS(type);
|
||||||
RS_SERIAL_PROCESS(name);
|
RS_SERIAL_PROCESS(name);
|
||||||
#if defined(__GNUC__) && !defined(__clang__)
|
|
||||||
# pragma GCC diagnostic ignored "-Wstrict-aliasing"
|
// (Cyril) We have to do this because on some systems (MacOS) uintptr_t is unsigned long which is not well defined. It is always
|
||||||
#endif // defined(__GNUC__) && !defined(__clang__)
|
// preferable to force type serialization to the correct size rather than letting the compiler choose for us.
|
||||||
std::uintptr_t& handle(reinterpret_cast<std::uintptr_t&>(ref));
|
// /!\ This structure cannot be sent over the network. The serialization would be inconsistent.
|
||||||
|
|
||||||
|
if(sizeof(ref) == 4)
|
||||||
|
{
|
||||||
|
std::uint32_t& handle(reinterpret_cast<std::uint32_t&>(ref));
|
||||||
RS_SERIAL_PROCESS(handle);
|
RS_SERIAL_PROCESS(handle);
|
||||||
#if defined(__GNUC__) && !defined(__clang__)
|
}
|
||||||
# pragma GCC diagnostic pop
|
else if(sizeof(ref) == 8)
|
||||||
#endif // defined(__GNUC__) && !defined(__clang__)
|
{
|
||||||
|
std::uint64_t& handle(reinterpret_cast<std::uint64_t&>(ref));
|
||||||
|
RS_SERIAL_PROCESS(handle);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
std::cerr << __PRETTY_FUNCTION__ << ": cannot serialize raw pointer of size " << sizeof(ref) << std::endl;
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue