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