From 77b99e8111cdd06b4fe12f2e18950a1e40ee2b76 Mon Sep 17 00:00:00 2001 From: Fabian Kosmale Date: Fri, 22 Oct 2021 12:36:06 +0200 Subject: QMetaType: Avoid superfluous template instantiations Apparently msvc still parses the template and generates code for it when it encounters an extern template declaration. Thus, instead of speeding up compilation, it gets slowed down significantly as the instantiation would happen in every compilation unit that (transitively) included qmetatype.h. Task-number: QTBUG-97601 Change-Id: Id5e934afb14ad8973df1b9197aef336b22220111 Reviewed-by: Thiago Macieira --- src/corelib/kernel/qmetatype.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/corelib/kernel/qmetatype.h') diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index 346ae3667a..669273af68 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -2369,9 +2369,13 @@ public: }; #undef QT_METATYPE_CONSTEXPRLAMDA -#ifndef QT_BOOTSTRAPPED +/* + MSVC instantiates extern templates +(https://developercommunity.visualstudio.com/t/c11-extern-templates-doesnt-work-for-class-templat/157868) + */ +#if !defined(QT_BOOTSTRAPPED) && !defined(Q_CC_MSVC) -#if !defined(Q_CC_MSVC) || !defined(QT_BUILD_CORE_LIB) +#if !defined(QT_BUILD_CORE_LIB) #define QT_METATYPE_TEMPLATE_EXPORT Q_CORE_EXPORT #else #define QT_METATYPE_TEMPLATE_EXPORT -- cgit v1.2.3