If you attempt to inherit a class from FThreadSingleton and that class is not in the Core module, you will get a compile error on Windows non-monolithic builds.
The reason is because FThreadSingleton is marked CORE_API, and VC++ expects any of those instantiations of FThreadSingleton::Get to be exported from Core.
Removing the CORE_API from the FThreadSingleton declaration of course causes compile errors with FMemoryStack and other classes which use it in Core, which is why I imagine it was added in the first place.
In the general case the solution to this is to explicitly export specific template instantiations from the DLL. This requires another macro for each module, CORE_TEMPLATE_EXTERN.
when compiling the module:
#define CORE_TEMPLATE_EXTERN extern
when compiling other modules
#define CORE_TEMPLATE_EXTERN
then to export the template instantiation:
CORE_TEMPLATE_EXTERN template class CORE_API Foo<Bob>;
Unfortunately, in this specific case, I’m not sure if this will work with the way FThreadSingleton is designed, because you get a chicken and egg scenario because the derived class is not fully defined and the template uses the derived class.
You could maybe try this, but I doubt it would work:
class FFoo;
CORE_TEMPLATE_EXTERN template class CORE_API FThreadSingleton<FFoo>;
class CORE_API FFoo : public FThreadSingleton<FFoo>
Not sure exactly how to work around this to be honest. For now I’m just duplicating the FThreadSingleton functionality in my class but it’d be nice to be able to use this helper in other modules.