From 3cc3ade1697b16f2c1d8e5b5c27bf303af27751a Mon Sep 17 00:00:00 2001 From: "Marco Antonio J. Costa" Date: Wed, 22 Jul 2026 13:09:48 -0300 Subject: [PATCH] declare the table specialisations before anything instantiates one TestTableTemplate declares SetRefresh and Init but never defines them; both exist only as explicit specialisations, one set per table, at the bottom of FacilityProduction.cpp and MilitiaWebsite.cpp. That is too late for tables 3 and 4. Both files call SetRefresh on their table hundreds of lines above the specialisation, and a call is a point of instantiation, so the compiler has already committed to instantiating the primary template by the time the specialisation shows up. A specialisation declared after the first use that would instantiate it is ill-formed; MSVC takes it anyway, clang-cl reports error: explicit specialization of 'SetRefresh' after instantiation Declaring the specialisations after the includes fixes it. Tables 1 and 2 are only ever reached through the base class pointer, so they were not diagnosed, but they are declared alongside the others rather than left to depend on that. The definitions stay where they are. --- Laptop/FacilityProduction.cpp | 5 +++++ Laptop/MilitiaWebsite.cpp | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/Laptop/FacilityProduction.cpp b/Laptop/FacilityProduction.cpp index e195b14ed..7dbac7864 100644 --- a/Laptop/FacilityProduction.cpp +++ b/Laptop/FacilityProduction.cpp @@ -18,6 +18,11 @@ #include "strategic.h" #include "BaseTable.h" +// Every member below is specialised for each table, and nothing else defines them. +// The specialisations have to be visible before the first use instantiates one. +template<> void TestTableTemplate<4>::SetRefresh(); +template<> void TestTableTemplate<4>::Init( UINT16 sX, UINT16 sY, UINT16 sX_End, UINT16 sY_End ); + /*#define MERCOMP_FONT_COLOR 2 #define CAMPHIS_FONT_BIG FONT14ARIAL #define CAMPHIS_FONT_MED FONT12ARIAL diff --git a/Laptop/MilitiaWebsite.cpp b/Laptop/MilitiaWebsite.cpp index 96e093d0a..ff72c023e 100644 --- a/Laptop/MilitiaWebsite.cpp +++ b/Laptop/MilitiaWebsite.cpp @@ -46,6 +46,15 @@ #include "InterfaceItemImages.h" #include "CampaignStats.h" +// Every member below is specialised for each table, and nothing else defines them. +// The specialisations have to be visible before the first use instantiates one. +template<> void TestTableTemplate<1>::SetRefresh(); +template<> void TestTableTemplate<1>::Init( UINT16 sX, UINT16 sY, UINT16 sX_End, UINT16 sY_End ); +template<> void TestTableTemplate<2>::SetRefresh(); +template<> void TestTableTemplate<2>::Init( UINT16 sX, UINT16 sY, UINT16 sX_End, UINT16 sY_End ); +template<> void TestTableTemplate<3>::SetRefresh(); +template<> void TestTableTemplate<3>::Init( UINT16 sX, UINT16 sY, UINT16 sX_End, UINT16 sY_End ); + #define MERCOMP_FONT_COLOR 2 #define CAMPHIS_FONT_COLOR_RED FONT_MCOLOR_RED