From d9f9bc9bada91e3ec2b6c496d3b2242506ca56bc Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Fri, 9 Oct 2020 15:54:01 +0200 Subject: QMetaType: Avoid combination of extern and declspec(__dllexport) on MSVC MSVC does strange things with this, and it actually tells us so via a warning. We can, however, attach the dllexport to the definition, rather than the declaration of the symbols in order to resolve the problem. Change-Id: I9971e13afc6d8840c49ec20d21820a72c5407200 Reviewed-by: Fabian Kosmale --- src/corelib/kernel/qmetatype.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/corelib/kernel/qmetatype.cpp') diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp index 60588e9329..c9a0a40cd0 100644 --- a/src/corelib/kernel/qmetatype.cpp +++ b/src/corelib/kernel/qmetatype.cpp @@ -2925,14 +2925,23 @@ QMetaType::QMetaType(int typeId) : QMetaType(interfaceForType(typeId)) {} namespace QtPrivate { #ifndef QT_BOOTSTRAPPED + +#if defined(Q_CC_MSVC) && defined(QT_BUILD_CORE_LIB) +#define QT_METATYPE_TEMPLATE_EXPORT Q_CORE_EXPORT +#else +#define QT_METATYPE_TEMPLATE_EXPORT +#endif + // Explicit instantiation definition -#define QT_METATYPE_DECLARE_TEMPLATE_ITER(TypeName, Id, Name) template class QMetaTypeForType; +#define QT_METATYPE_DECLARE_TEMPLATE_ITER(TypeName, Id, Name) \ + template class QT_METATYPE_TEMPLATE_EXPORT QMetaTypeForType; QT_FOR_EACH_STATIC_PRIMITIVE_TYPE(QT_METATYPE_DECLARE_TEMPLATE_ITER) QT_FOR_EACH_STATIC_PRIMITIVE_POINTER(QT_METATYPE_DECLARE_TEMPLATE_ITER) QT_FOR_EACH_STATIC_CORE_CLASS(QT_METATYPE_DECLARE_TEMPLATE_ITER) QT_FOR_EACH_STATIC_CORE_POINTER(QT_METATYPE_DECLARE_TEMPLATE_ITER) QT_FOR_EACH_STATIC_CORE_TEMPLATE(QT_METATYPE_DECLARE_TEMPLATE_ITER) #undef QT_METATYPE_DECLARE_TEMPLATE_ITER +#undef QT_METATYPE_TEMPLATE_EXPORT #endif } -- cgit v1.2.3