From 82456f220fb00414cf187fa6d92f106786f22b22 Mon Sep 17 00:00:00 2001 From: Andreas Schuh Date: Sun, 30 Sep 2018 20:28:22 -0700 Subject: [PATCH] =?UTF-8?q?fix:=20Declare=20FlagRegisterer=20c=E2=80=99tor?= =?UTF-8?q?=20explicit=20template=20instanations=20as=20extern=20in=20head?= =?UTF-8?q?er?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/gflags.h.in | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/gflags.h.in b/src/gflags.h.in index 1f1d907..b437862 100644 --- a/src/gflags.h.in +++ b/src/gflags.h.in @@ -441,6 +441,23 @@ class GFLAGS_DLL_DECL FlagRegisterer { FlagType* current_storage, FlagType* defvalue_storage); }; +// Force compiler to not generate code for the given template specialization. +#define GFLAGS_DECLARE_FLAG_REGISTERER_CTOR(type) \ + extern template GFLAGS_DLL_DECL FlagRegisterer::FlagRegisterer( \ + const char* name, const char* help, const char* filename, \ + type* current_storage, type* defvalue_storage) + +// Do this for all supported flag types. +GFLAGS_DECLARE_FLAG_REGISTERER_CTOR(bool); +GFLAGS_DECLARE_FLAG_REGISTERER_CTOR(int32); +GFLAGS_DECLARE_FLAG_REGISTERER_CTOR(uint32); +GFLAGS_DECLARE_FLAG_REGISTERER_CTOR(int64); +GFLAGS_DECLARE_FLAG_REGISTERER_CTOR(uint64); +GFLAGS_DECLARE_FLAG_REGISTERER_CTOR(double); +GFLAGS_DECLARE_FLAG_REGISTERER_CTOR(std::string); + +#undef GFLAGS_DECLARE_FLAG_REGISTERER_CTOR + // If your application #defines STRIP_FLAG_HELP to a non-zero value // before #including this file, we remove the help message from the // binary file. This can reduce the size of the resulting binary