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 | #include <QtCore/qtconfiginclude.h> |
13 | |
14 | /* |
15 | QT_VERSION is (major << 16) | (minor << 8) | patch. |
16 | */ |
17 | #define QT_VERSION QT_VERSION_CHECK(QT_VERSION_MAJOR, QT_VERSION_MINOR, QT_VERSION_PATCH) |
18 | /* |
19 | can be used like #if (QT_VERSION >= QT_VERSION_CHECK(6, 4, 0)) |
20 | */ |
21 | #define QT_VERSION_CHECK(major, minor, patch) ((major<<16)|(minor<<8)|(patch)) |
22 | |
23 | /* |
24 | Helper macros to make some simple code active in Qt 6 or Qt 7 only, |
25 | like: |
26 | struct QT6_ONLY(Q_CORE_EXPORT) QTrivialClass |
27 | { |
28 | void QT7_ONLY(Q_CORE_EXPORT) void operate(); |
29 | } |
30 | */ |
31 | #if QT_VERSION_MAJOR == 7 || defined(QT_BOOTSTRAPPED) |
32 | # define QT7_ONLY(...) __VA_ARGS__ |
33 | # define QT6_ONLY(...) |
34 | #elif QT_VERSION_MAJOR == 6 |
35 | # define QT7_ONLY(...) |
36 | # define QT6_ONLY(...) __VA_ARGS__ |
37 | #else |
38 | # error Qt major version not 6 or 7 |
39 | #endif |
40 | |
41 | /* Macro and tag type to help overload resolution on functions |
42 | that are, e.g., QT_REMOVED_SINCE'ed. Example use: |
43 | |
44 | #if QT_CORE_REMOVED_SINCE(6, 4) |
45 | int size() const; |
46 | #endif |
47 | qsizetype size(QT6_DECL_NEW_OVERLOAD) const; |
48 | |
49 | in the normal cpp file: |
50 | |
51 | qsizetype size(QT6_IMPL_NEW_OVERLOAD) const { |
52 | ~~~ |
53 | } |
54 | |
55 | in removed_api.cpp: |
56 | |
57 | int size() const { return int(size(QT6_CALL_NEW_OVERLOAD)); } |
58 | */ |
59 | #ifdef Q_QDOC |
60 | # define QT6_DECL_NEW_OVERLOAD |
61 | # define QT6_DECL_NEW_OVERLOAD_TAIL |
62 | # define QT6_IMPL_NEW_OVERLOAD |
63 | # define QT6_IMPL_NEW_OVERLOAD_TAIL |
64 | # define QT6_CALL_NEW_OVERLOAD |
65 | # define QT6_CALL_NEW_OVERLOAD_TAIL |
66 | #else |
67 | # define QT6_DECL_NEW_OVERLOAD QT6_ONLY(Qt::Disambiguated_t = Qt::Disambiguated) |
68 | # define QT6_DECL_NEW_OVERLOAD_TAIL QT6_ONLY(, QT6_DECL_NEW_OVERLOAD) |
69 | # define QT6_IMPL_NEW_OVERLOAD QT6_ONLY(Qt::Disambiguated_t) |
70 | # define QT6_IMPL_NEW_OVERLOAD_TAIL QT6_ONLY(, QT6_IMPL_NEW_OVERLOAD) |
71 | # define QT6_CALL_NEW_OVERLOAD QT6_ONLY(Qt::Disambiguated) |
72 | # define QT6_CALL_NEW_OVERLOAD_TAIL QT6_ONLY(, QT6_CALL_NEW_OVERLOAD) |
73 | #endif |
74 | |
75 | #endif /* QTVERSIONCHECKS_H */ |
76 | |