Skip to content

Commit 11882b6

Browse files
committed
make CEREAL_BIND_TO_ARCHIVES not have an unused function under GNU C / clang to keep them from warning
1 parent f5a9404 commit 11882b6

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

include/cereal/details/polymorphic_impl.hpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@
5656
#include <set>
5757
#include <stack>
5858

59+
//! Helper macro to omit unused warning
60+
#if defined(__GNUC__)
61+
// GCC / clang don't want the function
62+
#define CEREAL_BIND_TO_ARCHIVES_UNUSED_FUNCTION
63+
#else
64+
#define CEREAL_BIND_TO_ARCHIVES_UNUSED_FUNCTION static void unused() { (void)b; }
65+
#endif
66+
5967
//! Binds a polymorhic type to all registered archives
6068
/*! This binds a polymorphic type to all compatible registered archives that
6169
have been registered with CEREAL_REGISTER_ARCHIVE. This must be called
@@ -67,7 +75,7 @@
6775
template<> \
6876
struct init_binding<__VA_ARGS__> { \
6977
static bind_to_archives<__VA_ARGS__> const & b; \
70-
static void unused() { (void)b; } \
78+
CEREAL_BIND_TO_ARCHIVES_UNUSED_FUNCTION \
7179
}; \
7280
bind_to_archives<__VA_ARGS__> const & init_binding<__VA_ARGS__>::b = \
7381
::cereal::detail::StaticObject< \

0 commit comments

Comments
 (0)