Fix MSVC warning dllexport and extern are incompatible

C4910: '__declspec(dllexport)' and 'extern' are incompatible on an
explicit instantiation
This commit is contained in:
Urs Fleisch 2023-12-10 08:25:36 +01:00
parent c7babea74a
commit ec734bbe08
3 changed files with 7 additions and 3 deletions

View File

@ -37,7 +37,7 @@
#ifdef _MSC_VER
// Explained at end of tpropertymap.cpp
extern template class TAGLIB_EXPORT TagLib::Map<TagLib::String, TagLib::StringList>;
extern template class TagLib::Map<TagLib::String, TagLib::StringList>;
#endif
namespace TagLib {

View File

@ -205,5 +205,9 @@ PropertyMap &PropertyMap::operator=(const PropertyMap &other)
// Ogg::FieldListMap is used because this will instantiate the same template
// Map<String, StringList>. Therefore this template is instantiated here
// and declared extern in the headers using it.
template class TagLib::Map<TagLib::String, TagLib::StringList>;
// Suppress warning "needs to have dll-interface to be used by clients",
// in the template, TAGLIB_EXPORT cannot be used on the members, therefore
// the private implemenation is exported too, but not accessible by clients.
#pragma warning(suppress: 4251)
template class TAGLIB_EXPORT TagLib::Map<TagLib::String, TagLib::StringList>;
#endif

View File

@ -31,7 +31,7 @@
#ifdef _MSC_VER
// Explained at end of tpropertymap.cpp
extern template class TAGLIB_EXPORT TagLib::Map<TagLib::String, TagLib::StringList>;
extern template class TagLib::Map<TagLib::String, TagLib::StringList>;
#endif
namespace TagLib {