Skip to content

Commit 8d6b274

Browse files
author
Sona Kurazyan
committed
Extract header qtversionchecks.h from qglobal.h
Task-number: QTBUG-99313 Change-Id: Iaaa6a055367e861d095b92e3e85e5bc340e6bbc1 Reviewed-by: Thiago Macieira <[email protected]>
1 parent 908d048 commit 8d6b274

File tree

5 files changed

+69
-52
lines changed

5 files changed

+69
-52
lines changed

src/corelib/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ qt_internal_add_module(Core
7171
global/qtnamespacemacros.h
7272
global/qtrace_p.h
7373
global/qtranslation.h
74+
global/qtversionchecks.h
7475
global/qtypeinfo.h
7576
global/qvolatile_p.h
7677
global/q20algorithm.h

src/corelib/global/qglobal.cpp

-44
Original file line numberDiff line numberDiff line change
@@ -1214,50 +1214,6 @@ static_assert(sizeof(qint64) == 8, "Internal error, qint64 is misdefined");
12141214
\sa qMin(), qMax()
12151215
*/
12161216

1217-
/*!
1218-
\macro QT_VERSION_CHECK(major, minor, patch)
1219-
\relates <QtGlobal>
1220-
1221-
Turns the \a major, \a minor and \a patch numbers of a version into an
1222-
integer that encodes all three. When expressed in hexadecimal, this integer
1223-
is of form \c 0xMMNNPP wherein \c{0xMM ==} \a major, \c{0xNN ==} \a minor,
1224-
and \c{0xPP ==} \a patch. This can be compared with another similarly
1225-
processed version ID.
1226-
1227-
Example:
1228-
1229-
\snippet code/src_corelib_global_qglobal.cpp qt-version-check
1230-
1231-
\note the parameters are read as integers in the normal way, so should
1232-
normally be written in decimal (so a \c 0x prefix must be used if writing
1233-
them in hexadecimal). Thus \c{QT_VERSION_CHECK(5, 15, 0)} is equal to \c
1234-
0x050f00, which could equally be written \c{QT_VERSION_CHECK(5, 0xf, 0)}.
1235-
1236-
\sa QT_VERSION
1237-
*/
1238-
1239-
/*!
1240-
\macro QT_VERSION
1241-
\relates <QtGlobal>
1242-
1243-
This macro expands to a numeric value of the same form as \l
1244-
QT_VERSION_CHECK() constructs, that specifies the version of Qt with which
1245-
code using it is compiled. For example, if you compile your application with
1246-
Qt 6.1.2, the QT_VERSION macro will expand to \c 0x060102, the same as
1247-
\c{QT_VERSION_CHECK(6, 1, 2)}. Note that this need not agree with the
1248-
version the application will find itself using at \e runtime.
1249-
1250-
You can use QT_VERSION to select the latest Qt features where available
1251-
while falling back to older implementations otherwise. Using
1252-
QT_VERSION_CHECK() for the value to compare with is recommended.
1253-
1254-
Example:
1255-
1256-
\snippet code/src_corelib_global_qglobal.cpp 16
1257-
1258-
\sa QT_VERSION_STR, QT_VERSION_CHECK(), qVersion()
1259-
*/
1260-
12611217
/*!
12621218
\macro QT_VERSION_STR
12631219
\relates <QtGlobal>

src/corelib/global/qglobal.h

+1-8
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,7 @@
2222
# include <stddef.h>
2323
#endif
2424

25-
/*
26-
QT_VERSION is (major << 16) | (minor << 8) | patch.
27-
*/
28-
#define QT_VERSION QT_VERSION_CHECK(QT_VERSION_MAJOR, QT_VERSION_MINOR, QT_VERSION_PATCH)
29-
/*
30-
can be used like #if (QT_VERSION >= QT_VERSION_CHECK(6, 4, 0))
31-
*/
32-
#define QT_VERSION_CHECK(major, minor, patch) ((major<<16)|(minor<<8)|(patch))
25+
#include <QtCore/qtversionchecks.h>
3326

3427
#ifdef QT_BOOTSTRAPPED
3528
#include <QtCore/qconfig-bootstrapped.h>
+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Copyright (C) 2022 The Qt Company Ltd.
2+
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3+
4+
/*!
5+
\macro QT_VERSION_CHECK(major, minor, patch)
6+
\relates <QtVersionChecks>
7+
8+
Turns the \a major, \a minor and \a patch numbers of a version into an
9+
integer that encodes all three. When expressed in hexadecimal, this integer
10+
is of form \c 0xMMNNPP wherein \c{0xMM ==} \a major, \c{0xNN ==} \a minor,
11+
and \c{0xPP ==} \a patch. This can be compared with another similarly
12+
processed version ID.
13+
14+
Example:
15+
16+
\snippet code/src_corelib_global_qglobal.cpp qt-version-check
17+
18+
\note the parameters are read as integers in the normal way, so should
19+
normally be written in decimal (so a \c 0x prefix must be used if writing
20+
them in hexadecimal). Thus \c{QT_VERSION_CHECK(5, 15, 0)} is equal to \c
21+
0x050f00, which could equally be written \c{QT_VERSION_CHECK(5, 0xf, 0)}.
22+
23+
\sa QT_VERSION
24+
*/
25+
26+
/*!
27+
\macro QT_VERSION
28+
\relates <QtVersionChecks>
29+
30+
This macro expands to a numeric value of the same form as \l
31+
QT_VERSION_CHECK() constructs, that specifies the version of Qt with which
32+
code using it is compiled. For example, if you compile your application with
33+
Qt 6.1.2, the QT_VERSION macro will expand to \c 0x060102, the same as
34+
\c{QT_VERSION_CHECK(6, 1, 2)}. Note that this need not agree with the
35+
version the application will find itself using at \e runtime.
36+
37+
You can use QT_VERSION to select the latest Qt features where available
38+
while falling back to older implementations otherwise. Using
39+
QT_VERSION_CHECK() for the value to compare with is recommended.
40+
41+
Example:
42+
43+
\snippet code/src_corelib_global_qglobal.cpp 16
44+
45+
\sa QT_VERSION_STR, QT_VERSION_CHECK(), qVersion()
46+
*/

src/corelib/global/qtversionchecks.h

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright (C) 2022 The Qt Company Ltd.
2+
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3+
4+
#ifndef QTVERSIONCHECKS_H
5+
#define QTVERSIONCHECKS_H
6+
7+
#if 0
8+
#pragma qt_class(QtVersionChecks)
9+
#pragma qt_sync_stop_processing
10+
#endif
11+
12+
/*
13+
QT_VERSION is (major << 16) | (minor << 8) | patch.
14+
*/
15+
#define QT_VERSION QT_VERSION_CHECK(QT_VERSION_MAJOR, QT_VERSION_MINOR, QT_VERSION_PATCH)
16+
/*
17+
can be used like #if (QT_VERSION >= QT_VERSION_CHECK(6, 4, 0))
18+
*/
19+
#define QT_VERSION_CHECK(major, minor, patch) ((major<<16)|(minor<<8)|(patch))
20+
21+
#endif /* QTVERSIONCHECKS_H */

0 commit comments

Comments
 (0)