From 18461d676fd23f8f8f2b3c6db1d184df2e543d2d Mon Sep 17 00:00:00 2001 From: Kenneth Moreland Date: Mon, 28 Mar 2022 09:18:23 -0600 Subject: [PATCH] Add a unique symbol to InstantiationTemplate.cxx.in A compiler or linker may give an error if a .cxx file is empty (that is, declares no symbols). This can happen if an instantiation declaration gets removed during the compile either through preprocessor macros or SFINAE. To protect against this, declare a simple integer with a unique symbol in each instantiation file. The overhead is very small and will prevent compile/link errors. --- CMake/InstantiationTemplate.cxx.in | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMake/InstantiationTemplate.cxx.in b/CMake/InstantiationTemplate.cxx.in index 841c1aa1c..5988886f6 100644 --- a/CMake/InstantiationTemplate.cxx.in +++ b/CMake/InstantiationTemplate.cxx.in @@ -4,6 +4,9 @@ #include <@INSTANTIATION_TEMPLATE_SOURCE@> +/* Needed for linking errors when no instantiations */ +int @INSTANTIATION_INC_GUARD@@counter@__; + @INSTANTIATION_DECLARATION@ #undef @INSTANTIATION_INC_GUARD@