diff --git a/include/cereal/types/polymorphic.hpp b/include/cereal/types/polymorphic.hpp index 5acc11f8a..5c33d8e8d 100644 --- a/include/cereal/types/polymorphic.hpp +++ b/include/cereal/types/polymorphic.hpp @@ -165,17 +165,19 @@ See CEREAL_REGISTER_DYNAMIC_INIT for detailed explanation of how this macro should be used. The name used should match that for CEREAL_REGISTER_DYNAMIC_INIT. */ -#define CEREAL_FORCE_DYNAMIC_INIT(LibName) \ - namespace cereal { \ - namespace detail { \ - void dynamic_init_dummy_##LibName(); \ - } /* end detail */ \ - namespace { \ - void dynamic_init_##LibName() \ - { \ - ::cereal::detail::dynamic_init_dummy_##LibName(); \ - } \ - } } /* end namespaces */ +#define CEREAL_FORCE_DYNAMIC_INIT(LibName) \ + namespace cereal { \ + namespace detail { \ + void dynamic_init_dummy_##LibName(); \ + } /* end detail */ \ + } /* end cereal */ \ + namespace { \ + struct dynamic_init_##LibName { \ + dynamic_init_##LibName() { \ + ::cereal::detail::dynamic_init_dummy_##LibName(); \ + } \ + } dynamic_init_instance_##LibName; \ + } /* end anonymous namespace */ namespace cereal {