summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSona Kurazyan <sona.kurazyan@qt.io>2022-08-30 10:37:00 +0200
committerSona Kurazyan <sona.kurazyan@qt.io>2022-09-01 13:26:30 +0200
commit50b05e3e2ad969abf4b939d5db2253380e47d775 (patch)
tree8234f369db98fb720b19f6e14714dd8653b3801d /src
parentb077c419eaafe82ada9ed723165b5c4bfcc80b12 (diff)
Move qVersion() from qglobal.h to qlibraryinfo.h
Since qVersion() might be called also from C code, disable the parts of qlibraryinfo.h that are relevant only for C++ code if __cplusplus is not defined. [ChangeLog][Potentially Source-Incompatible Changes] qVersion() is moved from qglobal.h to qlibraryinfo.h, '#include <QtCore/QLibraryInfo>' needs to be added where it's used. Task-number: QTBUG-99313 Change-Id: I3363ef3fa4073114e5151cb3a2a1e8282ad42a4d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/global/qglobal.cpp15
-rw-r--r--src/corelib/global/qglobal.h13
-rw-r--r--src/corelib/global/qlibraryinfo.cpp15
-rw-r--r--src/corelib/global/qlibraryinfo.h21
-rw-r--r--src/gui/accessible/linux/atspiadaptor.cpp1
5 files changed, 37 insertions, 28 deletions
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index 0e5b2d5b80..ffc899da8b 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -792,21 +792,6 @@ using namespace Qt::StringLiterals;
\sa qVersion(), QT_VERSION
*/
-/*!
- \relates <QtGlobal>
-
- Returns the version number of Qt at runtime as a string (for example,
- "6.1.2"). This may be a different version than the version the application
- was \e compiled with.
-
- \sa QT_VERSION_STR, QLibraryInfo::version()
-*/
-
-const char *qVersion() noexcept
-{
- return QT_VERSION_STR;
-}
-
/*****************************************************************************
System detection routines
*****************************************************************************/
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index c55b6ee754..6a247f9ea4 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -48,19 +48,6 @@ inline void qt_noop(void) {}
#ifndef __ASSEMBLER__
QT_BEGIN_NAMESPACE
-/*
- * If we're compiling C++ code:
- * - and this is a non-namespace build, declare qVersion as extern "C"
- * - and this is a namespace build, declare it as a regular function
- * (we're already inside QT_BEGIN_NAMESPACE / QT_END_NAMESPACE)
- * If we're compiling C code, simply declare the function. If Qt was compiled
- * in a namespace, qVersion isn't callable anyway.
- */
-#if !defined(QT_NAMESPACE) && defined(__cplusplus) && !defined(Q_QDOC)
-extern "C"
-#endif
-Q_CORE_EXPORT Q_DECL_CONST_FUNCTION const char *qVersion(void) Q_DECL_NOEXCEPT;
-
#if defined(__cplusplus)
#if 0
diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp
index 5b148dd42c..fe9bc218aa 100644
--- a/src/corelib/global/qlibraryinfo.cpp
+++ b/src/corelib/global/qlibraryinfo.cpp
@@ -659,6 +659,21 @@ QStringList QLibraryInfo::platformPluginArguments(const QString &platformName)
\deprecated Use LibraryPath with QLibraryInfo::path() instead.
*/
+/*!
+ \relates <QLibraryInfo>
+
+ Returns the version number of Qt at runtime as a string (for example,
+ "6.1.2"). This is the version of the Qt library in use at \e runtime,
+ which need not be the version the application was \e compiled with.
+
+ \sa QT_VERSION_STR, QLibraryInfo::version()
+*/
+
+const char *qVersion() noexcept
+{
+ return QT_VERSION_STR;
+}
+
#if QT_DEPRECATED_SINCE(6, 9)
bool qSharedBuild() noexcept
diff --git a/src/corelib/global/qlibraryinfo.h b/src/corelib/global/qlibraryinfo.h
index d4e8f8b050..71d9a01308 100644
--- a/src/corelib/global/qlibraryinfo.h
+++ b/src/corelib/global/qlibraryinfo.h
@@ -4,12 +4,18 @@
#ifndef QLIBRARYINFO_H
#define QLIBRARYINFO_H
+#if defined(__cplusplus)
#include <QtCore/qstring.h>
#include <QtCore/qdatetime.h>
#include <QtCore/qversionnumber.h>
+#else
+#include <QtCore/qglobal.h>
+#endif
QT_BEGIN_NAMESPACE
+#if defined(__cplusplus)
+
class Q_CORE_EXPORT QLibraryInfo
{
public:
@@ -61,6 +67,21 @@ Q_CORE_EXPORT Q_DECL_CONST_FUNCTION bool qSharedBuild() noexcept;
#endif
+#endif // __cplusplus
+
+/*
+ * If we're compiling C++ code:
+ * - and this is a non-namespace build, declare qVersion as extern "C"
+ * - and this is a namespace build, declare it as a regular function
+ * (we're already inside QT_BEGIN_NAMESPACE / QT_END_NAMESPACE)
+ * If we're compiling C code, simply declare the function. If Qt was compiled
+ * in a namespace, qVersion isn't callable anyway.
+ */
+#if !defined(QT_NAMESPACE) && defined(__cplusplus) && !defined(Q_QDOC)
+extern "C"
+#endif
+Q_CORE_EXPORT Q_DECL_CONST_FUNCTION const char *qVersion(void) Q_DECL_NOEXCEPT;
+
QT_END_NAMESPACE
#endif // QLIBRARYINFO_H
diff --git a/src/gui/accessible/linux/atspiadaptor.cpp b/src/gui/accessible/linux/atspiadaptor.cpp
index 91d0e47415..46b4fbe0dc 100644
--- a/src/gui/accessible/linux/atspiadaptor.cpp
+++ b/src/gui/accessible/linux/atspiadaptor.cpp
@@ -11,6 +11,7 @@
#include <qclipboard.h>
#include <QtCore/qloggingcategory.h>
+#include <QtCore/qlibraryinfo.h>
#if QT_CONFIG(accessibility)
#include "socket_interface.h"