summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSona Kurazyan <[email protected]>2022-08-30 10:37:00 +0200
committerSona Kurazyan <[email protected]>2022-09-01 13:26:30 +0200
commit50b05e3e2ad969abf4b939d5db2253380e47d775 (patch)
tree8234f369db98fb720b19f6e14714dd8653b3801d
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 <[email protected]> Reviewed-by: Edward Welbourne <[email protected]>
-rw-r--r--qmake/generators/makefile.cpp1
-rw-r--r--qmake/generators/unix/unixmake2.cpp1
-rw-r--r--qmake/option.cpp1
-rw-r--r--qmake/property.cpp1
-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
-rw-r--r--tests/auto/corelib/global/qglobal/qglobal.c1
-rw-r--r--tests/auto/corelib/global/qglobal/tst_qglobal.cpp1
-rw-r--r--tests/manual/highdpi/dprgadget/main.cpp1
-rw-r--r--tests/manual/shortcuts/main.cpp1
13 files changed, 45 insertions, 28 deletions
diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp
index 4c21ef8202b..06ca1807a73 100644
--- a/qmake/generators/makefile.cpp
+++ b/qmake/generators/makefile.cpp
@@ -16,6 +16,7 @@
#include <qdebug.h>
#include <qbuffer.h>
#include <qdatetime.h>
+#include <qlibraryinfo.h>
#if defined(Q_OS_UNIX)
#include <unistd.h>
diff --git a/qmake/generators/unix/unixmake2.cpp b/qmake/generators/unix/unixmake2.cpp
index 98c7e217cf0..1b2989b9788 100644
--- a/qmake/generators/unix/unixmake2.cpp
+++ b/qmake/generators/unix/unixmake2.cpp
@@ -10,6 +10,7 @@
#include <qfile.h>
#include <qdir.h>
#include <qdebug.h>
+#include <qlibraryinfo.h>
#include <time.h>
#include <tuple>
diff --git a/qmake/option.cpp b/qmake/option.cpp
index f0e6c503412..55f21120c0c 100644
--- a/qmake/option.cpp
+++ b/qmake/option.cpp
@@ -12,6 +12,7 @@
#include <stdarg.h>
#include <qmakelibraryinfo.h>
+#include <qlibraryinfo.h>
#include <private/qlibraryinfo_p.h>
QT_BEGIN_NAMESPACE
diff --git a/qmake/property.cpp b/qmake/property.cpp
index 358d7f3a3c2..6ac13213554 100644
--- a/qmake/property.cpp
+++ b/qmake/property.cpp
@@ -5,6 +5,7 @@
#include <qdir.h>
#include <qsettings.h>
+#include <qlibraryinfo.h>
#include <qmakelibraryinfo.h>
#include <qstringlist.h>
#include <stdio.h>
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index 0e5b2d5b805..ffc899da8bc 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 c55b6ee754b..6a247f9ea4e 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 5b148dd42cf..fe9bc218aa5 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 d4e8f8b0506..71d9a013080 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 91d0e47415c..46b4fbe0dc3 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"
diff --git a/tests/auto/corelib/global/qglobal/qglobal.c b/tests/auto/corelib/global/qglobal/qglobal.c
index 3b898de39ff..64569f4de7b 100644
--- a/tests/auto/corelib/global/qglobal/qglobal.c
+++ b/tests/auto/corelib/global/qglobal/qglobal.c
@@ -2,6 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include <QtCore/qglobal.h>
+#include <QtCore/qlibraryinfo.h>
#ifdef Q_COMPILER_THREAD_LOCAL
# include <threads.h>
diff --git a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp
index 752fb948a5d..3923b6d6ac3 100644
--- a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp
+++ b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp
@@ -8,6 +8,7 @@
#include <QSysInfo>
#include <QLatin1String>
#include <QString>
+#include <QLibraryInfo>
#include <cmath>
diff --git a/tests/manual/highdpi/dprgadget/main.cpp b/tests/manual/highdpi/dprgadget/main.cpp
index 9da74b48936..c8d7add901f 100644
--- a/tests/manual/highdpi/dprgadget/main.cpp
+++ b/tests/manual/highdpi/dprgadget/main.cpp
@@ -1,6 +1,7 @@
// Copyright (C) 2020 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+#include <QtCore/qlibraryinfo.h>
#include <QtGui/qpa/qplatformscreen.h>
#include <QtGui/qpa/qplatformwindow.h>
#include <QtGui/private/qhighdpiscaling_p.h>
diff --git a/tests/manual/shortcuts/main.cpp b/tests/manual/shortcuts/main.cpp
index e7127f37964..bcdd47cab75 100644
--- a/tests/manual/shortcuts/main.cpp
+++ b/tests/manual/shortcuts/main.cpp
@@ -8,6 +8,7 @@
#include <QLabel>
#include <QPushButton>
#include <QDebug>
+#include <QLibraryInfo>
class ShortcutTester : public QWidget
{