mirror of
https://github.com/RPCS3/cereal.git
synced 2025-02-17 06:07:59 +00:00
Fix unused var warning for static vars, add cmake rules for shared lib sandbox
This commit is contained in:
parent
c2f881de5b
commit
419343a0c5
@ -204,6 +204,7 @@ namespace cereal
|
||||
std::type_index(typeid(TYPE)).hash_code(), VERSION_NUMBER ); \
|
||||
return VERSION_NUMBER; \
|
||||
} \
|
||||
static void unused() { (void)version; } \
|
||||
}; /* end Version */ \
|
||||
const std::uint32_t Version<TYPE>::version = \
|
||||
Version<TYPE>::registerVersion(); \
|
||||
|
@ -62,12 +62,13 @@
|
||||
template<> \
|
||||
struct init_binding<T> { \
|
||||
static bind_to_archives<T> const & b; \
|
||||
static void unused() { (void)b; } \
|
||||
}; \
|
||||
bind_to_archives<T> const & init_binding<T>::b = \
|
||||
::cereal::detail::StaticObject< \
|
||||
bind_to_archives<T> \
|
||||
>::getInstance().bind(); \
|
||||
}} // end namespaces
|
||||
}} /* end namespaces */
|
||||
|
||||
namespace cereal
|
||||
{
|
||||
|
@ -1,9 +1,12 @@
|
||||
add_subdirectory(sandbox_shared_lib)
|
||||
|
||||
add_executable(sandbox sandbox.cpp)
|
||||
add_executable(sandbox_json sandbox_json.cpp)
|
||||
add_executable(sandbox_rtti sandbox_rtti.cpp)
|
||||
if( WIN32 )
|
||||
add_executable(sandbox_vs sandbox_vs.cpp)
|
||||
endif( WIN32 )
|
||||
|
||||
add_executable(sandbox_vs sandbox_vs.cpp)
|
||||
target_link_libraries(sandbox_vs sandbox_vs_dll)
|
||||
include_directories(sandbox_shared_lib)
|
||||
|
||||
if(Boost_FOUND)
|
||||
add_executable(performance performance.cpp)
|
||||
|
@ -1,15 +1,9 @@
|
||||
#ifndef CEREAL_DLL_USE
|
||||
#define CEREAL_DLL_MAKE
|
||||
#endif
|
||||
#include "base.hpp"
|
||||
|
||||
//CEREAL_REGISTER_SHARED_LIBRARY(Sandbox)
|
||||
template void Base::serialize<cereal::XMLOutputArchive>
|
||||
( cereal::XMLOutputArchive & ar, std::uint32_t const version );
|
||||
template void Base::serialize<cereal::XMLInputArchive>
|
||||
( cereal::XMLInputArchive & ar, std::uint32_t const version );
|
||||
|
||||
//template <class Archive>
|
||||
//void Base::serialize(Archive & ar, std::uint32_t const version)
|
||||
//{
|
||||
//}
|
||||
#ifndef CEREAL_DLL_USE
|
||||
#define CEREAL_DLL_MAKE
|
||||
#endif
|
||||
#include "base.hpp"
|
||||
|
||||
template void Base::serialize<cereal::XMLOutputArchive>
|
||||
( cereal::XMLOutputArchive & ar, std::uint32_t const version );
|
||||
template void Base::serialize<cereal::XMLInputArchive>
|
||||
( cereal::XMLInputArchive & ar, std::uint32_t const version );
|
||||
|
@ -1,41 +1,43 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <cereal/cereal.hpp>
|
||||
#include <cereal/archives/xml.hpp>
|
||||
#include <cereal/types/polymorphic.hpp>
|
||||
|
||||
#if defined (_WINDLL)
|
||||
#define DECLSPECIFIER __declspec(dllexport)
|
||||
#else
|
||||
#define DECLSPECIFIER __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
int doit();
|
||||
|
||||
class VersionTest
|
||||
{
|
||||
public:
|
||||
int x;
|
||||
template <class Archive>
|
||||
void serialize( Archive & ar, const std::uint32_t /* version */ )
|
||||
{ ar( x ); }
|
||||
};
|
||||
|
||||
class Base
|
||||
{
|
||||
public:
|
||||
friend class cereal::access;
|
||||
|
||||
template < class Archive >
|
||||
void serialize(Archive & ar, std::uint32_t const version) {}
|
||||
virtual ~Base() {}
|
||||
};
|
||||
|
||||
extern template DECLSPECIFIER void Base::serialize<cereal::XMLInputArchive>
|
||||
( cereal::XMLInputArchive & ar, std::uint32_t const version );
|
||||
|
||||
extern template DECLSPECIFIER void Base::serialize<cereal::XMLOutputArchive>
|
||||
( cereal::XMLOutputArchive & ar, std::uint32_t const version );
|
||||
|
||||
CEREAL_CLASS_VERSION(VersionTest, 1)
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <cereal/cereal.hpp>
|
||||
#include <cereal/archives/xml.hpp>
|
||||
#include <cereal/types/polymorphic.hpp>
|
||||
|
||||
#if defined (_WINDLL)
|
||||
#define DECLSPECIFIER __declspec(dllexport)
|
||||
#elif defined(MSC_VER)
|
||||
#define DECLSPECIFIER __declspec(dllimport)
|
||||
#else
|
||||
#define DECLSPECIFIER
|
||||
#endif
|
||||
|
||||
int doit();
|
||||
|
||||
class VersionTest
|
||||
{
|
||||
public:
|
||||
int x;
|
||||
template <class Archive>
|
||||
void serialize( Archive & ar, const std::uint32_t /* version */ )
|
||||
{ ar( x ); }
|
||||
};
|
||||
|
||||
class Base
|
||||
{
|
||||
public:
|
||||
friend class cereal::access;
|
||||
|
||||
template < class Archive >
|
||||
void serialize(Archive &, std::uint32_t const) {}
|
||||
virtual ~Base() {}
|
||||
};
|
||||
|
||||
extern template DECLSPECIFIER void Base::serialize<cereal::XMLInputArchive>
|
||||
( cereal::XMLInputArchive & ar, std::uint32_t const version );
|
||||
|
||||
extern template DECLSPECIFIER void Base::serialize<cereal::XMLOutputArchive>
|
||||
( cereal::XMLOutputArchive & ar, std::uint32_t const version );
|
||||
|
||||
CEREAL_CLASS_VERSION(VersionTest, 1)
|
||||
|
@ -1,20 +1,10 @@
|
||||
#ifndef CEREAL_DLL_USE
|
||||
#define CEREAL_DLL_MAKE
|
||||
#endif
|
||||
#include "derived.hpp"
|
||||
|
||||
//CEREAL_REGISTER_TYPE_DLL(Derived)
|
||||
//CEREAL_REGISTER_SHARED_LIBRARY(Sandbox)
|
||||
|
||||
template void Derived::serialize<cereal::XMLOutputArchive>
|
||||
( cereal::XMLOutputArchive & ar, std::uint32_t const version );
|
||||
|
||||
template void Derived::serialize<cereal::XMLInputArchive>
|
||||
( cereal::XMLInputArchive & ar, std::uint32_t const version );
|
||||
|
||||
//template <class Archive>
|
||||
//void Derived::serialize(Archive & ar, std::uint32_t const version)
|
||||
//{
|
||||
// std::cout << "Hello from " << __LINE__ << std::endl;
|
||||
// ar(cereal::base_class<Base>(this));
|
||||
//}
|
||||
#ifndef CEREAL_DLL_USE
|
||||
#define CEREAL_DLL_MAKE
|
||||
#endif
|
||||
#include "derived.hpp"
|
||||
|
||||
template void Derived::serialize<cereal::XMLOutputArchive>
|
||||
( cereal::XMLOutputArchive & ar, std::uint32_t const version );
|
||||
|
||||
template void Derived::serialize<cereal::XMLInputArchive>
|
||||
( cereal::XMLInputArchive & ar, std::uint32_t const version );
|
||||
|
@ -1,20 +1,19 @@
|
||||
#pragma once
|
||||
#include "base.hpp"
|
||||
class Derived : public Base
|
||||
{
|
||||
private:
|
||||
friend class cereal::access;
|
||||
template <class Archive>
|
||||
void serialize(Archive & ar, std::uint32_t const version)
|
||||
{
|
||||
std::cout << "\nHello from " << __LINE__ << std::endl;
|
||||
::cereal::detail::StaticObject<cereal::detail::bind_to_archives<Derived>>::getInstance();
|
||||
ar(cereal::base_class<Base>(this));
|
||||
}
|
||||
};
|
||||
extern template DECLSPECIFIER void Derived::serialize<cereal::XMLOutputArchive>
|
||||
( cereal::XMLOutputArchive & ar, std::uint32_t const version );
|
||||
extern template DECLSPECIFIER void Derived::serialize<cereal::XMLInputArchive>
|
||||
( cereal::XMLInputArchive & ar, std::uint32_t const version );
|
||||
|
||||
CEREAL_REGISTER_TYPE(Derived)
|
||||
#pragma once
|
||||
#include "base.hpp"
|
||||
class Derived : public Base
|
||||
{
|
||||
private:
|
||||
friend class cereal::access;
|
||||
template <class Archive>
|
||||
void serialize(Archive & ar, std::uint32_t const)
|
||||
{
|
||||
ar(cereal::base_class<Base>(this));
|
||||
}
|
||||
};
|
||||
|
||||
extern template DECLSPECIFIER void Derived::serialize<cereal::XMLOutputArchive>
|
||||
( cereal::XMLOutputArchive & ar, std::uint32_t const version );
|
||||
extern template DECLSPECIFIER void Derived::serialize<cereal::XMLInputArchive>
|
||||
( cereal::XMLInputArchive & ar, std::uint32_t const version );
|
||||
|
||||
CEREAL_REGISTER_TYPE(Derived)
|
||||
|
@ -144,7 +144,7 @@ struct C
|
||||
char a;
|
||||
};
|
||||
|
||||
CEREAL_REGISTER_TYPE(B);
|
||||
CEREAL_REGISTER_TYPE(B)
|
||||
|
||||
class MemberMinimal
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user