exporting template member function of template class from dll
- From: "Hyd" <hkapell@xxxxxxxxx>
- Date: 29 Aug 2005 02:14:23 -0700
Hi all!
I have something like that :
******** dll.h ********
#ifdef CC_EXPORTS // CC_EXPORTS is defined in the dll.
#define __CC_API __declspec(dllexport)
#define __CC_TEMPLATE_API( iTemplate ) template class __CC_API
iTemplate;
#else
#define __CC_API __declspec(dllimport)
#define __CC_TEMPLATE_API( iTemplate ) extern template class __CC_API
iTemplate;
#endif
namespace CC
{
template<class TChar = char>
class SString
{
...
int Length() const
{
...
};
template<class _TChar>
void Append( const _TChar* ipFormat, ... )
{
...
};
};
}
__CC_TEMPLATE_API( CC::SString<char> )
******** exe.cpp ********
#include "dll.h" // CC_EXPORTS is defined in the dll.
using namespace CC;
int main()
{
SString<char> str;
int len = str.Length();
str << "My SString : ";
str.Append( "%s %.3f\n", "double", 1.2156 );
str.Append( "%s 0x%04X\n", "Hexadecimal :", 2005 );
return 0;
}
*************************
I have no problem with non-template member functions, but with template
member functions (like Append), the VC++ 6 Compiler gives me an error :
dll.obj : error LNK2001: unresolved external symbol
"__declspec(dllimport) public: void __cdecl
CC::SString<char>::Append(char const *,...)"
(__imp_?Append@?$SString@D@CC@@QAAXPBDZZ)
How can I resolve this problem ? I would like to have the code of the
Append<_TChar> member function in the dll (for _TChar = char and _TChar
= wchar_t).
Thanks,
.
- Follow-Ups:
- Re: exporting template member function of template class from dll
- From: Carl Daniel [VC++ MVP]
- Re: exporting template member function of template class from dll
- From: Rodrigo Corral [MVP]
- Re: exporting template member function of template class from dll
- Prev by Date: Re: _CrtMemCheckpoint & _CrtMemDumpAllObjectsSince
- Next by Date: Re: CreateFile and multithreading
- Previous by thread: CreateFile and multithreading
- Next by thread: Re: exporting template member function of template class from dll
- Index(es):
Relevant Pages
|