GithubHelp home page GithubHelp logo

Comments (4)

AzothAmmo avatar AzothAmmo commented on July 17, 2024

I have a fix for this incoming that is essentially your solution with a ton of documentation. We're going to have two versions of CEREAL_REGISTER_TYPE, one that does the binding and one that doesn't do it.

from cereal.

AzothAmmo avatar AzothAmmo commented on July 17, 2024

After thinking about this some more I'm not convinced that we need to split things off into a header macro e.g. CEREAL_REGISTER_TYPE_WITHOUT_BINDING (that would avoid calling CEREAL_BIND_TO_ARCHIVES(T)) and a separate definition macro (CEREAL_BIND_TO_ARCHIVES(T)).

In all of the tests I've done we can solve the issue by moving CEREAL_REGISTER_TYPE into a .cpp file. We've been doing this in shared library code and some simple static library code. See https://gist.github.com/AzothAmmo/a56b63b225a0886eddc2 for the example I've been working with.

If you can think of any situations which break this idiom (putting it in the .cpp files) let us know.

from cereal.

sithhell avatar sithhell commented on July 17, 2024

Looks like it is working! Thanks for the resolution.

If that solution turns out to work in our project, you guys are my heros. We are currently dealing with massive compile time and link times because boost.serialization is instantiating an insane amount of code. If we only have to do the registration in the source files means a big win.

from cereal.

chenghuige avatar chenghuige commented on July 17, 2024

Below might fix this problem

#define CEREAL_BIND_TO_ARCHIVES(T)
namespace cereal {
namespace detail {
template<>
struct init_binding {
static bind_to_archives const & b()
{
const static bind_to_archives _b = ::cereal::detail::StaticObject<bind_to_archives >::getInstance().bind(); \
return _b;
}
static void unused() { (void)b(); }
}; \
}} /* end namespaces */

from cereal.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.