我的班级包含std::map<std::string, int>
和std::map<std::string, std::map<std::string, int>>
。我试图导出STL对象。我正在关注给定here
#include <map>
#include <string>
#include <vector>
#ifdef AIRCRAFTCONFIGDLL_EXPORTS
#define AIRCRAFTCONFIGDLL_API __declspec(dllexport)
#define EXPIMP_TEMPLATE
#else
#define AIRCRAFTCONFIGDLL_API __declspec(dllimport)
#define EXPIMP_TEMPLATE
#endif
EXPIMP_TEMPLATE template struct AIRCRAFTCONFIGDLL_API std::less<std::string>;
EXPIMP_TEMPLATE template class AIRCRAFTCONFIGDLL_API std::allocator<std::string>;
EXPIMP_TEMPLATE template class AIRCRAFTCONFIGDLL_API std::allocator<std::pair<const std::string, int>>;
EXPIMP_TEMPLATE template class AIRCRAFTCONFIGDLL_API std::map<std::string, int>;
EXPIMP_TEMPLATE template class AIRCRAFTCONFIGDLL_API std::allocator<std::pair<const std::string, std::map<std::string, int>>>;
EXPIMP_TEMPLATE template class AIRCRAFTCONFIGDLL_API std::map<std::string, std::map<std::string, int>>;
class AIRCRAFTCONFIGDLL_API CAircraftConfig
{
.
.
.
但突然间我的警告真的很毛茸茸。我需要包含所有这些疯狂的分配器还是有更好的方法?
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\map(81): warning C4251: 'std::_Tree_nod<_Traits>::_Alnod' : class 'std::allocator<_Ty>' needs to have dll-interface to be used by clients of class 'std::_Tree_nod<_Traits>'
1> with
1> [
1> _Traits=std::_Tmap_traits<std::string,int,std::less<std::string>,std::allocator<std::pair<const std::string,int>>,false>
1> ]
1> and
1> [
1> _Ty=std::_Tree_nod<std::_Tmap_traits<std::string,int,std::less<std::string>,std::allocator<std::pair<const std::string,int>>,false>>::_Node
1> ]
1> and
1> [
1> _Traits=std::_Tmap_traits<std::string,int,std::less<std::string>,std::allocator<std::pair<const std::string,int>>,false>
1> ]
1> c:\uaepgjtac\release_3.x-development\pilotstationballisticlibrary\aircraftconfigdll\aircraftconfigdll.h(20) : see reference to class template instantiation 'std::map<_Kty,_Ty>' being compiled
1> with
1> [
1> _Kty=std::string,
1> _Ty=int
1> ]