From: Mikko Rasa Date: Tue, 1 Nov 2016 22:00:55 +0000 (+0200) Subject: Move the definition of PacketTypeDef::class_id to a separate header X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=8248f2912454229f4ded72b8fb4db3e76ea3ad15;p=libs%2Fnet.git Move the definition of PacketTypeDef::class_id to a separate header Defining it in protocol.h may cause multiple definitions to appear across the program and there are cases where they don't get collapsed to one. DLLs on Windows are one such case. The _impl header is to be included in files that add packet definitions to a protocol and nowhere else. --- diff --git a/source/net/communicator.cpp b/source/net/communicator.cpp index 3d6353a..22a7963 100644 --- a/source/net/communicator.cpp +++ b/source/net/communicator.cpp @@ -1,5 +1,6 @@ #include #include "communicator.h" +#include "protocol_impl.h" #include "streamsocket.h" using namespace std; diff --git a/source/net/protocol.cpp b/source/net/protocol.cpp index b24cef1..52678af 100644 --- a/source/net/protocol.cpp +++ b/source/net/protocol.cpp @@ -5,6 +5,7 @@ #include #include #include "protocol.h" +#include "protocol_impl.h" using namespace std; diff --git a/source/net/protocol.h b/source/net/protocol.h index 7ff63cb..05ea60e 100644 --- a/source/net/protocol.h +++ b/source/net/protocol.h @@ -455,9 +455,6 @@ const char *Protocol::Serializer::deserialize(P &pkt, const char *bu } -template -unsigned Protocol::PacketTypeDef

::class_id = 0; - template Protocol::PacketTypeDef

::PacketTypeDef(unsigned i): PacketDefBase(i), diff --git a/source/net/protocol_impl.h b/source/net/protocol_impl.h new file mode 100644 index 0000000..9ddf818 --- /dev/null +++ b/source/net/protocol_impl.h @@ -0,0 +1,15 @@ +#ifndef MSP_NET_PROTOCOL_IMPL_H_ +#define MSP_NET_PROTOCOL_IMPL_H_ + +#include "protocol.h" + +namespace Msp { +namespace Net { + +template +unsigned Protocol::PacketTypeDef

::class_id = 0; + +} // namespace Net +} // namespace Msp + +#endif