Создал шаблон DLL в Visual Studio .NET, добавил в класс одну строчку vector<int> vi; и полчил неприятное предупреждение:
h:\c\dlltest\dlltest.h(20) : warning C4251: 'Cdlltest::vi' : class 'std::vector<_Ty>' needs to have dll-interface to be used by clients of class 'Cdlltest'
with
[
_Ty=int
]
Почитал тут:
How To Exporting STL Components Inside & Outside of a Class но реально это работает только с VC6.
Если я добавляю explicit instantiation: template class __declspec(dllexport) vector<int>, как рекомендовано, перед определением класса, то получаю более замысловатое предупреждение в VC7.1:
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\vector(35) : warning C4251: 'std::_Vector_val<_Ty,_Alloc>::_Alval' : class 'std::allocator<_Ty>' needs to have dll-interface to be used by clients of class 'std::_Vector_val<_Ty,_Alloc>'
with
[
_Ty=int,
_Alloc=std::allocator<int>
]
and
[
_Ty=int
]
and
[
_Ty=int,
_Alloc=std::allocator<int>
]
h:\c\dlltest\dlltest.h(15) : see reference to class template instantiation 'std::vector<_Ty>' being compiled
with
[
_Ty=int
]
Можно ли (и нужно ли) бороться с этим предупреждением, если можно и нужно то как?
Спасибо.