I can instantiate and MFC-export a function, but am unable to instantiate a templated function. I need the template to be defined generically so I can instantiate it elsewhere in the translation unit.
The sample code shows using MFC __declspec(dllexport)
to export these functions:
// ExportTmpldFunc.h
void __declspec( dllexport ) MyFunc(); // MFC exported function declaration
template< class T >
void __declspec( dllexport ) MyTmpldFunc(); // primary MFC exported function template declaration
// ExportTmpldFunc.cpp
#include "ExportTmpldFunc.h"
void MyFunc() // function definition implicitly instantiated
{}
template< class T >
void MyTmpldFunc() // function template defined, but not instantiated
{}
// attempt1 to instantiate
template<> void MyTmpldFunc< int >() // explicit function template specialization defined, but not instantiated for MSVC
{}
// attempt2 to instantiate
template void MyTmpldFunc< int >(); // explicit function template instantiation definition, but still not instantiated for MSVC