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 QTDEPRECATIONMARKERS_H |
5 | #define QTDEPRECATIONMARKERS_H |
6 | |
7 | #include <QtCore/qtconfigmacros.h> |
8 | #include <QtCore/qtclasshelpermacros.h> |
9 | #include <QtCore/qtdeprecationdefinitions.h> |
10 | #include <QtCore/qtversionchecks.h> |
11 | #include <QtCore/qcompilerdetection.h> // for Q_DECL_DEPRECATED |
12 | |
13 | #if 0 |
14 | #pragma qt_class(QtDeprecationMarkers) |
15 | #pragma qt_sync_stop_processing |
16 | #endif |
17 | |
18 | QT_BEGIN_NAMESPACE |
19 | |
20 | #if defined(QT_NO_DEPRECATED) |
21 | # undef QT_DEPRECATED |
22 | # undef QT_DEPRECATED_X |
23 | # undef QT_DEPRECATED_VARIABLE |
24 | # undef QT_DEPRECATED_CONSTRUCTOR |
25 | #elif !defined(QT_NO_DEPRECATED_WARNINGS) |
26 | # undef QT_DEPRECATED |
27 | # define QT_DEPRECATED Q_DECL_DEPRECATED |
28 | # undef QT_DEPRECATED_X |
29 | # define QT_DEPRECATED_X(text) Q_DECL_DEPRECATED_X(text) |
30 | # undef QT_DEPRECATED_VARIABLE |
31 | # define QT_DEPRECATED_VARIABLE Q_DECL_VARIABLE_DEPRECATED |
32 | # undef QT_DEPRECATED_CONSTRUCTOR |
33 | # define QT_DEPRECATED_CONSTRUCTOR Q_DECL_CONSTRUCTOR_DEPRECATED explicit |
34 | #else |
35 | # undef QT_DEPRECATED |
36 | # define QT_DEPRECATED |
37 | # undef QT_DEPRECATED_X |
38 | # define QT_DEPRECATED_X(text) |
39 | # undef QT_DEPRECATED_VARIABLE |
40 | # define QT_DEPRECATED_VARIABLE |
41 | # undef QT_DEPRECATED_CONSTRUCTOR |
42 | # define QT_DEPRECATED_CONSTRUCTOR |
43 | # undef Q_DECL_ENUMERATOR_DEPRECATED |
44 | # define Q_DECL_ENUMERATOR_DEPRECATED |
45 | # undef Q_DECL_ENUMERATOR_DEPRECATED_X |
46 | # define Q_DECL_ENUMERATOR_DEPRECATED_X(ignored) |
47 | #endif |
48 | |
49 | /* |
50 | QT_DEPRECATED_SINCE(major, minor) evaluates as true if the Qt version is greater than |
51 | the deprecation point specified. |
52 | |
53 | Use it to specify from which version of Qt a function or class has been deprecated |
54 | |
55 | Example: |
56 | #if QT_DEPRECATED_SINCE(5,1) |
57 | QT_DEPRECATED void deprecatedFunction(); //function deprecated since Qt 5.1 |
58 | #endif |
59 | |
60 | */ |
61 | #ifdef QT_DEPRECATED |
62 | #define QT_DEPRECATED_SINCE(major, minor) (QT_VERSION_CHECK(major, minor, 0) > QT_DISABLE_DEPRECATED_UP_TO) |
63 | #else |
64 | #define QT_DEPRECATED_SINCE(major, minor) 0 |
65 | #endif |
66 | |
67 | /* |
68 | QT_DEPRECATED_VERSION(major, minor) and QT_DEPRECATED_VERSION_X(major, minor, text) |
69 | outputs a deprecation warning if QT_WARN_DEPRECATED_UP_TO is equal to or greater |
70 | than the version specified as major, minor. This makes it possible to deprecate a |
71 | function without annoying a user who needs to stay compatible with a specified minimum |
72 | version and therefore can't use the new function. |
73 | */ |
74 | #if QT_WARN_DEPRECATED_UP_TO >= QT_VERSION_CHECK(5, 12, 0) |
75 | # define QT_DEPRECATED_VERSION_X_5_12(text) QT_DEPRECATED_X(text) |
76 | # define QT_DEPRECATED_VERSION_5_12 QT_DEPRECATED |
77 | #else |
78 | # define QT_DEPRECATED_VERSION_X_5_12(text) |
79 | # define QT_DEPRECATED_VERSION_5_12 |
80 | #endif |
81 | |
82 | #if QT_WARN_DEPRECATED_UP_TO >= QT_VERSION_CHECK(5, 13, 0) |
83 | # define QT_DEPRECATED_VERSION_X_5_13(text) QT_DEPRECATED_X(text) |
84 | # define QT_DEPRECATED_VERSION_5_13 QT_DEPRECATED |
85 | #else |
86 | # define QT_DEPRECATED_VERSION_X_5_13(text) |
87 | # define QT_DEPRECATED_VERSION_5_13 |
88 | #endif |
89 | |
90 | #if QT_WARN_DEPRECATED_UP_TO >= QT_VERSION_CHECK(5, 14, 0) |
91 | # define QT_DEPRECATED_VERSION_X_5_14(text) QT_DEPRECATED_X(text) |
92 | # define QT_DEPRECATED_VERSION_5_14 QT_DEPRECATED |
93 | #else |
94 | # define QT_DEPRECATED_VERSION_X_5_14(text) |
95 | # define QT_DEPRECATED_VERSION_5_14 |
96 | #endif |
97 | |
98 | #if QT_WARN_DEPRECATED_UP_TO >= QT_VERSION_CHECK(5, 15, 0) |
99 | # define QT_DEPRECATED_VERSION_X_5_15(text) QT_DEPRECATED_X(text) |
100 | # define QT_DEPRECATED_VERSION_5_15 QT_DEPRECATED |
101 | #else |
102 | # define QT_DEPRECATED_VERSION_X_5_15(text) |
103 | # define QT_DEPRECATED_VERSION_5_15 |
104 | #endif |
105 | |
106 | #if QT_WARN_DEPRECATED_UP_TO >= QT_VERSION_CHECK(6, 0, 0) |
107 | # define QT_DEPRECATED_VERSION_X_6_0(text) QT_DEPRECATED_X(text) |
108 | # define QT_DEPRECATED_VERSION_6_0 QT_DEPRECATED |
109 | #else |
110 | # define QT_DEPRECATED_VERSION_X_6_0(text) |
111 | # define QT_DEPRECATED_VERSION_6_0 |
112 | #endif |
113 | |
114 | #if QT_WARN_DEPRECATED_UP_TO >= QT_VERSION_CHECK(6, 1, 0) |
115 | # define QT_DEPRECATED_VERSION_X_6_1(text) QT_DEPRECATED_X(text) |
116 | # define QT_DEPRECATED_VERSION_6_1 QT_DEPRECATED |
117 | #else |
118 | # define QT_DEPRECATED_VERSION_X_6_1(text) |
119 | # define QT_DEPRECATED_VERSION_6_1 |
120 | #endif |
121 | |
122 | #if QT_WARN_DEPRECATED_UP_TO >= QT_VERSION_CHECK(6, 2, 0) |
123 | # define QT_DEPRECATED_VERSION_X_6_2(text) QT_DEPRECATED_X(text) |
124 | # define QT_DEPRECATED_VERSION_6_2 QT_DEPRECATED |
125 | #else |
126 | # define QT_DEPRECATED_VERSION_X_6_2(text) |
127 | # define QT_DEPRECATED_VERSION_6_2 |
128 | #endif |
129 | |
130 | #if QT_WARN_DEPRECATED_UP_TO >= QT_VERSION_CHECK(6, 3, 0) |
131 | # define QT_DEPRECATED_VERSION_X_6_3(text) QT_DEPRECATED_X(text) |
132 | # define QT_DEPRECATED_VERSION_6_3 QT_DEPRECATED |
133 | #else |
134 | # define QT_DEPRECATED_VERSION_X_6_3(text) |
135 | # define QT_DEPRECATED_VERSION_6_3 |
136 | #endif |
137 | |
138 | #if QT_WARN_DEPRECATED_UP_TO >= QT_VERSION_CHECK(6, 4, 0) |
139 | # define QT_DEPRECATED_VERSION_X_6_4(text) QT_DEPRECATED_X(text) |
140 | # define QT_DEPRECATED_VERSION_6_4 QT_DEPRECATED |
141 | #else |
142 | # define QT_DEPRECATED_VERSION_X_6_4(text) |
143 | # define QT_DEPRECATED_VERSION_6_4 |
144 | #endif |
145 | |
146 | #if QT_WARN_DEPRECATED_UP_TO >= QT_VERSION_CHECK(6, 5, 0) |
147 | # define QT_DEPRECATED_VERSION_X_6_5(text) QT_DEPRECATED_X(text) |
148 | # define QT_DEPRECATED_VERSION_6_5 QT_DEPRECATED |
149 | #else |
150 | # define QT_DEPRECATED_VERSION_X_6_5(text) |
151 | # define QT_DEPRECATED_VERSION_6_5 |
152 | #endif |
153 | |
154 | #if QT_WARN_DEPRECATED_UP_TO >= QT_VERSION_CHECK(6, 6, 0) |
155 | # define QT_DEPRECATED_VERSION_X_6_6(text) QT_DEPRECATED_X(text) |
156 | # define QT_DEPRECATED_VERSION_6_6 QT_DEPRECATED |
157 | #else |
158 | # define QT_DEPRECATED_VERSION_X_6_6(text) |
159 | # define QT_DEPRECATED_VERSION_6_6 |
160 | #endif |
161 | |
162 | #if QT_WARN_DEPRECATED_UP_TO >= QT_VERSION_CHECK(6, 7, 0) |
163 | # define QT_DEPRECATED_VERSION_X_6_7(text) QT_DEPRECATED_X(text) |
164 | # define QT_DEPRECATED_VERSION_6_7 QT_DEPRECATED |
165 | #else |
166 | # define QT_DEPRECATED_VERSION_X_6_7(text) |
167 | # define QT_DEPRECATED_VERSION_6_7 |
168 | #endif |
169 | |
170 | #if QT_WARN_DEPRECATED_UP_TO >= QT_VERSION_CHECK(6, 8, 0) |
171 | # define QT_DEPRECATED_VERSION_X_6_8(text) QT_DEPRECATED_X(text) |
172 | # define QT_DEPRECATED_VERSION_6_8 QT_DEPRECATED |
173 | #else |
174 | # define QT_DEPRECATED_VERSION_X_6_8(text) |
175 | # define QT_DEPRECATED_VERSION_6_8 |
176 | #endif |
177 | |
178 | #if QT_WARN_DEPRECATED_UP_TO >= QT_VERSION_CHECK(6, 9, 0) |
179 | # define QT_DEPRECATED_VERSION_X_6_9(text) QT_DEPRECATED_X(text) |
180 | # define QT_DEPRECATED_VERSION_6_9 QT_DEPRECATED |
181 | #else |
182 | # define QT_DEPRECATED_VERSION_X_6_9(text) |
183 | # define QT_DEPRECATED_VERSION_6_9 |
184 | #endif |
185 | |
186 | #if QT_WARN_DEPRECATED_UP_TO >= QT_VERSION_CHECK(6, 10, 0) |
187 | # define QT_DEPRECATED_VERSION_X_6_10(text) QT_DEPRECATED_X(text) |
188 | # define QT_DEPRECATED_VERSION_6_10 QT_DEPRECATED |
189 | #else |
190 | # define QT_DEPRECATED_VERSION_X_6_10(text) |
191 | # define QT_DEPRECATED_VERSION_6_10 |
192 | #endif |
193 | |
194 | #if QT_WARN_DEPRECATED_UP_TO >= QT_VERSION_CHECK(6, 11, 0) |
195 | # define QT_DEPRECATED_VERSION_X_6_11(text) QT_DEPRECATED_X(text) |
196 | # define QT_DEPRECATED_VERSION_6_11 QT_DEPRECATED |
197 | #else |
198 | # define QT_DEPRECATED_VERSION_X_6_11(text) |
199 | # define QT_DEPRECATED_VERSION_6_11 |
200 | #endif |
201 | |
202 | #define QT_DEPRECATED_VERSION_X_5(minor, text) QT_DEPRECATED_VERSION_X_5_##minor(text) |
203 | #define QT_DEPRECATED_VERSION_X(major, minor, text) QT_DEPRECATED_VERSION_X_##major##_##minor(text) |
204 | |
205 | #define QT_DEPRECATED_VERSION_5(minor) QT_DEPRECATED_VERSION_5_##minor |
206 | #define QT_DEPRECATED_VERSION(major, minor) QT_DEPRECATED_VERSION_##major##_##minor |
207 | |
208 | /* |
209 | QT_IF_DEPRECATED_SINCE(major, minor, whenTrue, whenFalse) expands to |
210 | \a whenTrue if the specified (\a major, \a minor) version is less than or |
211 | equal to the deprecation version defined by QT_DISABLE_DEPRECATED_UP_TO, |
212 | and to \a whenFalse otherwise. |
213 | |
214 | Currently used for QT_INLINE_SINCE(maj, min), but can also be helpful for |
215 | other macros of that kind. |
216 | |
217 | The implementation uses QT_DEPRECATED_SINCE(maj, min) to define a bunch of |
218 | helper QT_IF_DEPRECATED_SINCE_X_Y macros, which expand to \a whenTrue or |
219 | \a whenFalse depending on the value of QT_DEPRECATED_SINCE. |
220 | |
221 | If you need to use QT_IF_DEPRECATED_SINCE() for a (major, minor) version, |
222 | that is not yet covered by the list below, you need to copy the definition |
223 | and change the major and minor versions accordingly. For example, for |
224 | version (X, Y), you will need to add |
225 | |
226 | \code |
227 | #if QT_DEPRECATED_SINCE(X, Y) |
228 | # define QT_IF_DEPRECATED_SINCE_X_Y(whenTrue, whenFalse) whenFalse |
229 | #else |
230 | # define QT_IF_DEPRECATED_SINCE_X_Y(whenTrue, whenFalse) whenTrue |
231 | #endif |
232 | \endcode |
233 | */ |
234 | |
235 | #define QT_IF_DEPRECATED_SINCE(major, minor, whenTrue, whenFalse) \ |
236 | QT_IF_DEPRECATED_SINCE_ ## major ## _ ## minor(whenTrue, whenFalse) |
237 | |
238 | #if QT_DEPRECATED_SINCE(6, 0) |
239 | # define QT_IF_DEPRECATED_SINCE_6_0(whenTrue, whenFalse) whenFalse |
240 | #else |
241 | # define QT_IF_DEPRECATED_SINCE_6_0(whenTrue, whenFalse) whenTrue |
242 | #endif |
243 | |
244 | #if QT_DEPRECATED_SINCE(6, 1) |
245 | # define QT_IF_DEPRECATED_SINCE_6_1(whenTrue, whenFalse) whenFalse |
246 | #else |
247 | # define QT_IF_DEPRECATED_SINCE_6_1(whenTrue, whenFalse) whenTrue |
248 | #endif |
249 | |
250 | #if QT_DEPRECATED_SINCE(6, 2) |
251 | # define QT_IF_DEPRECATED_SINCE_6_2(whenTrue, whenFalse) whenFalse |
252 | #else |
253 | # define QT_IF_DEPRECATED_SINCE_6_2(whenTrue, whenFalse) whenTrue |
254 | #endif |
255 | |
256 | #if QT_DEPRECATED_SINCE(6, 3) |
257 | # define QT_IF_DEPRECATED_SINCE_6_3(whenTrue, whenFalse) whenFalse |
258 | #else |
259 | # define QT_IF_DEPRECATED_SINCE_6_3(whenTrue, whenFalse) whenTrue |
260 | #endif |
261 | |
262 | #if QT_DEPRECATED_SINCE(6, 4) |
263 | # define QT_IF_DEPRECATED_SINCE_6_4(whenTrue, whenFalse) whenFalse |
264 | #else |
265 | # define QT_IF_DEPRECATED_SINCE_6_4(whenTrue, whenFalse) whenTrue |
266 | #endif |
267 | |
268 | #if QT_DEPRECATED_SINCE(6, 5) |
269 | # define QT_IF_DEPRECATED_SINCE_6_5(whenTrue, whenFalse) whenFalse |
270 | #else |
271 | # define QT_IF_DEPRECATED_SINCE_6_5(whenTrue, whenFalse) whenTrue |
272 | #endif |
273 | |
274 | #if QT_DEPRECATED_SINCE(6, 6) |
275 | # define QT_IF_DEPRECATED_SINCE_6_6(whenTrue, whenFalse) whenFalse |
276 | #else |
277 | # define QT_IF_DEPRECATED_SINCE_6_6(whenTrue, whenFalse) whenTrue |
278 | #endif |
279 | |
280 | #if QT_DEPRECATED_SINCE(6, 7) |
281 | # define QT_IF_DEPRECATED_SINCE_6_7(whenTrue, whenFalse) whenFalse |
282 | #else |
283 | # define QT_IF_DEPRECATED_SINCE_6_7(whenTrue, whenFalse) whenTrue |
284 | #endif |
285 | |
286 | #if QT_DEPRECATED_SINCE(6, 8) |
287 | # define QT_IF_DEPRECATED_SINCE_6_8(whenTrue, whenFalse) whenFalse |
288 | #else |
289 | # define QT_IF_DEPRECATED_SINCE_6_8(whenTrue, whenFalse) whenTrue |
290 | #endif |
291 | |
292 | #if QT_DEPRECATED_SINCE(6, 9) |
293 | # define QT_IF_DEPRECATED_SINCE_6_9(whenTrue, whenFalse) whenFalse |
294 | #else |
295 | # define QT_IF_DEPRECATED_SINCE_6_9(whenTrue, whenFalse) whenTrue |
296 | #endif |
297 | |
298 | #if QT_DEPRECATED_SINCE(6, 10) |
299 | # define QT_IF_DEPRECATED_SINCE_6_10(whenTrue, whenFalse) whenFalse |
300 | #else |
301 | # define QT_IF_DEPRECATED_SINCE_6_10(whenTrue, whenFalse) whenTrue |
302 | #endif |
303 | |
304 | #if QT_DEPRECATED_SINCE(6, 11) |
305 | # define QT_IF_DEPRECATED_SINCE_6_11(whenTrue, whenFalse) whenFalse |
306 | #else |
307 | # define QT_IF_DEPRECATED_SINCE_6_11(whenTrue, whenFalse) whenTrue |
308 | #endif |
309 | |
310 | #ifdef __cplusplus |
311 | // A tag to help mark stuff deprecated (cf. QStringViewLiteral) |
312 | namespace QtPrivate { |
313 | inline QT_DEFINE_TAG(Deprecated); |
314 | } |
315 | #endif |
316 | |
317 | #ifdef QT_ASCII_CAST_WARNINGS |
318 | # define QT_ASCII_CAST_WARN \ |
319 | Q_DECL_DEPRECATED_X("Use fromUtf8, QStringLiteral, or QLatin1StringView") |
320 | #else |
321 | # define QT_ASCII_CAST_WARN |
322 | #endif |
323 | |
324 | QT_END_NAMESPACE |
325 | |
326 | #endif // QTDEPRECATIONMARKERS_H |
327 | |