
Exporting STL containers (specifically std::map) from DLL?
Hello,
I recently moved to using VC7 (7.0.9466) from VC6 since I had some classes
that were derived from and/or contained STL containers other than vector<>
that I need to export from a DLL. Since VC6 didn't support exporting those
classes, I tried VC7, which seems to work. I still get lots of warnings
during my compiles and I have some unanswered questions.
I'm trying to use the following:
class __declspec(dllexport) CBase {...};
template <class K, class D> class __declspec(dllexport) CListBase : public
CBase, public std::map<K, D> {
iterator Find(const K&key);
const_iterator Find(const K&key) const;
Quote:
};
class __declspec(dllexport) CList1 : public CListBase<mykey, mydata> {...};
(NOTE: class mydata has operator<(const class mydata) and operator==(const
class mydata).)
1. Do I have to explicitly instantiate template specializations in my DLL?
2. If I just export std::map<mykey,mydata>, I get the C4251 warnings
'std::_Tmap_traits<_Kty,_Ty,_Pr,_Alloc,_Mfl>::comp' : struct
'std::less<_Ty>', 'std::_Tree_nod<_Traits>::_Alnod' : class
'std::allocator<_Ty>'
and
'std::_Tree_ptr<_Traits>::_Alptr' : class 'std::allocator<_Ty>'
Do I need to worry about these warnings, and if so how do I get rid of them
(without #pragma warning ( disable : 4251 ))?
3. It seems whether I instantiate the specializations or not, when I look
at the resultant DLL with depends.exe, the appropriate specializations seem
to already be in the DLL.
The latest MSDN didn't seem to have any updated information on exporting STL
containers.
Thanks in advance for any help.
Al Dorundo