From 22662d7dba89794075d3bc3355ba128481e68a6d Mon Sep 17 00:00:00 2001 From: Yuhang Zhao <2546789017@qq.com> Date: Mon, 22 Aug 2022 09:57:24 +0800 Subject: QLibraryInfo: Add isSharedBuild() function and deprecate qSharedBuild() Now that there's QLibraryInfo::isDebugBuild(), it's better to also have QLibraryInfo::isSharedBuild() at the same time. It's also a very useful information about the current Qt build. I think debug/release and static/shared are the most important properties of a library, so it's better to have them both. Deprecate the global function qSharedBuild() in favor of the newly introduced QLibraryInfo::isSharedBuild(). As a drive-by, add the nodiscard attribute to both functions. [ChangeLog][QtCore] Added QLibraryInfo::isSharedBuild() and deprecated qSharedBuild(). Change-Id: I48fa0dc5eeca97e709d5267733fa70aae244174f Reviewed-by: Thiago Macieira --- src/corelib/global/qlibraryinfo.cpp | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'src/corelib/global/qlibraryinfo.cpp') diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index 755a4c6c39..5b148dd42c 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -235,6 +235,19 @@ QLibraryInfo::isDebugBuild() noexcept #endif } +/*! + \since 6.5 + Returns \c true if this is a shared (dynamic) build of Qt. +*/ +bool QLibraryInfo::isSharedBuild() noexcept +{ +#ifdef QT_SHARED + return true; +#else + return false; +#endif +} + /*! \since 5.8 Returns the version of the Qt library. @@ -646,15 +659,15 @@ QStringList QLibraryInfo::platformPluginArguments(const QString &platformName) \deprecated Use LibraryPath with QLibraryInfo::path() instead. */ +#if QT_DEPRECATED_SINCE(6, 9) + bool qSharedBuild() noexcept { -#ifdef QT_SHARED - return true; -#else - return false; -#endif + return QLibraryInfo::isSharedBuild(); } +#endif // QT_DEPRECATED_SINCE(6, 9) + QT_END_NAMESPACE #if defined(Q_CC_GNU) && defined(ELF_INTERPRETER) -- cgit v1.2.3