From 89a0ed100977a86f12ce0837b4d7787b88f09922 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 1 Apr 2021 23:59:55 -0700 Subject: [PATCH] Allow qrandom_p.h to be included by more than one .cpp in QtCore I thought we could use C++17 inline variables, but those can't be used across DLL boundaries: qrandom_p.h:75:48: error: definition of 'QBasicAtomicInteger qt_randomdevice_control' is marked 'dllimport' Change-Id: Id2983978ad544ff79911fffd1671f857587ef2fb Reviewed-by: Giuseppe D'Angelo --- src/corelib/global/qrandom.cpp | 4 ++++ src/corelib/global/qrandom_p.h | 4 +--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/corelib/global/qrandom.cpp b/src/corelib/global/qrandom.cpp index 6db8121028a..c978228094c 100644 --- a/src/corelib/global/qrandom.cpp +++ b/src/corelib/global/qrandom.cpp @@ -92,6 +92,10 @@ enum { FillBufferNoexcept = true }; +#if defined(QT_BUILD_INTERNAL) +QBasicAtomicInteger qt_randomdevice_control = Q_BASIC_ATOMIC_INITIALIZER(0U); +#endif + struct QRandomGenerator::SystemGenerator { #if QT_CONFIG(getentropy) diff --git a/src/corelib/global/qrandom_p.h b/src/corelib/global/qrandom_p.h index 052aef262ef..7e228b3fde4 100644 --- a/src/corelib/global/qrandom_p.h +++ b/src/corelib/global/qrandom_p.h @@ -71,9 +71,7 @@ enum RNGType { MersenneTwister = 1 }; -#if defined(QT_BUILD_INTERNAL) && defined(QT_BUILD_CORE_LIB) -Q_CORE_EXPORT QBasicAtomicInteger qt_randomdevice_control = Q_BASIC_ATOMIC_INITIALIZER(0U); -#elif defined(QT_BUILD_INTERNAL) +#if defined(QT_BUILD_INTERNAL) extern Q_CORE_EXPORT QBasicAtomicInteger qt_randomdevice_control; #else static const struct