From 93cd5c5f2f6c23bae83c907b6381dca9492e9eff Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 6 Jul 2017 16:57:28 +0200 Subject: options/value: try "extern template" for code size --- compat/linkage-macros.hpp | 3 +++ options/value.cpp | 3 +++ options/value.hpp | 23 +++++++++++++++++++++++ 3 files changed, 29 insertions(+) create mode 100644 options/value.cpp diff --git a/compat/linkage-macros.hpp b/compat/linkage-macros.hpp index 460e7ee5..a4c4b351 100644 --- a/compat/linkage-macros.hpp +++ b/compat/linkage-macros.hpp @@ -7,3 +7,6 @@ # define OTR_GENERIC_EXPORT __attribute__ ((visibility ("default"))) # define OTR_GENERIC_IMPORT #endif + +#define OTR_TEMPLATE_EXPORT template class OTR_GENERIC_EXPORT +#define OTR_TEMPLATE_IMPORT extern template class OTR_GENERIC_IMPORT diff --git a/options/value.cpp b/options/value.cpp new file mode 100644 index 00000000..39bf0506 --- /dev/null +++ b/options/value.cpp @@ -0,0 +1,3 @@ +// instantiate the "template class" value symbols +#define OTR_OPT_VALUE_TMPL_EXPORT +#include "value.hpp" diff --git a/options/value.hpp b/options/value.hpp index ba482cf7..be3e4be2 100644 --- a/options/value.hpp +++ b/options/value.hpp @@ -130,4 +130,27 @@ private: const t def; }; +#if defined OTR_OPT_VALUE_TMPL_EXPORT && defined BUILD_OPTIONS +# define OTR_OPT_VALUE OTR_TEMPLATE_EXPORT +#else +# define OTR_OPT_VALUE OTR_TEMPLATE_IMPORT +#endif + +OTR_OPT_VALUE value; +OTR_OPT_VALUE value; +OTR_OPT_VALUE value; +OTR_OPT_VALUE value; +OTR_OPT_VALUE value; +OTR_OPT_VALUE value; +OTR_OPT_VALUE value; +OTR_OPT_VALUE value; + +OTR_OPT_VALUE value>; +OTR_OPT_VALUE value>; +OTR_OPT_VALUE value>; +OTR_OPT_VALUE value>; +OTR_OPT_VALUE value>; +OTR_OPT_VALUE value>; +OTR_OPT_VALUE value>; + } // ns options -- cgit v1.2.3