1/* GLIB - Library of useful routines for C programming
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
3 *
4 * SPDX-License-Identifier: LGPL-2.1-or-later
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
18 */
19
20/*
21 * Modified by the GLib Team and others 1997-2000. See the AUTHORS
22 * file for a list of people on the GLib Team. See the ChangeLog
23 * files for a list of changes. These files are distributed with
24 * GLib at ftp://ftp.gtk.org/pub/gtk/.
25 */
26
27#ifndef __G_VERSION_MACROS_H__
28#define __G_VERSION_MACROS_H__
29
30#if !defined(__GLIB_H_INSIDE__) && !defined(GLIB_COMPILATION)
31#error "Only <glib.h> can be included directly."
32#endif
33
34/* Version boundaries checks */
35
36/**
37 * G_ENCODE_VERSION:
38 * @major: major version number
39 * @minor: minor version number
40 *
41 * Encode a major.minor version as a single integer.
42 *
43 * This is the encoding used by macros such as `GLIB_VERSION_2_84` and
44 * `GLIB_VERSION_CUR_STABLE`, and is intended to be used when (for example)
45 * setting the value of `GLIB_VERSION_MAX_ALLOWED`.
46 *
47 * Since: 2.32
48 */
49#define G_ENCODE_VERSION(major, minor) ((major) << 16 | (minor) << 8)
50
51/**
52* GLIB_VERSION_2_2:
53*
54* A macro that evaluates to the 2.2 version of GLib, in a format
55* that can be used by the C pre-processor.
56*
57* Since: 2.32
58*/
59#define GLIB_VERSION_2_2 (G_ENCODE_VERSION (2, 2))
60/**
61* GLIB_VERSION_2_4:
62*
63* A macro that evaluates to the 2.4 version of GLib, in a format
64* that can be used by the C pre-processor.
65*
66* Since: 2.32
67*/
68#define GLIB_VERSION_2_4 (G_ENCODE_VERSION (2, 4))
69/**
70* GLIB_VERSION_2_6:
71*
72* A macro that evaluates to the 2.6 version of GLib, in a format
73* that can be used by the C pre-processor.
74*
75* Since: 2.32
76*/
77#define GLIB_VERSION_2_6 (G_ENCODE_VERSION (2, 6))
78/**
79* GLIB_VERSION_2_8:
80*
81* A macro that evaluates to the 2.8 version of GLib, in a format
82* that can be used by the C pre-processor.
83*
84* Since: 2.32
85*/
86#define GLIB_VERSION_2_8 (G_ENCODE_VERSION (2, 8))
87/**
88* GLIB_VERSION_2_10:
89*
90* A macro that evaluates to the 2.10 version of GLib, in a format
91* that can be used by the C pre-processor.
92*
93* Since: 2.32
94*/
95#define GLIB_VERSION_2_10 (G_ENCODE_VERSION (2, 10))
96/**
97* GLIB_VERSION_2_12:
98*
99* A macro that evaluates to the 2.12 version of GLib, in a format
100* that can be used by the C pre-processor.
101*
102* Since: 2.32
103*/
104#define GLIB_VERSION_2_12 (G_ENCODE_VERSION (2, 12))
105/**
106* GLIB_VERSION_2_14:
107*
108* A macro that evaluates to the 2.14 version of GLib, in a format
109* that can be used by the C pre-processor.
110*
111* Since: 2.32
112*/
113#define GLIB_VERSION_2_14 (G_ENCODE_VERSION (2, 14))
114/**
115* GLIB_VERSION_2_16:
116*
117* A macro that evaluates to the 2.16 version of GLib, in a format
118* that can be used by the C pre-processor.
119*
120* Since: 2.32
121*/
122#define GLIB_VERSION_2_16 (G_ENCODE_VERSION (2, 16))
123/**
124* GLIB_VERSION_2_18:
125*
126* A macro that evaluates to the 2.18 version of GLib, in a format
127* that can be used by the C pre-processor.
128*
129* Since: 2.32
130*/
131#define GLIB_VERSION_2_18 (G_ENCODE_VERSION (2, 18))
132/**
133* GLIB_VERSION_2_20:
134*
135* A macro that evaluates to the 2.20 version of GLib, in a format
136* that can be used by the C pre-processor.
137*
138* Since: 2.32
139*/
140#define GLIB_VERSION_2_20 (G_ENCODE_VERSION (2, 20))
141/**
142* GLIB_VERSION_2_22:
143*
144* A macro that evaluates to the 2.22 version of GLib, in a format
145* that can be used by the C pre-processor.
146*
147* Since: 2.32
148*/
149#define GLIB_VERSION_2_22 (G_ENCODE_VERSION (2, 22))
150/**
151* GLIB_VERSION_2_24:
152*
153* A macro that evaluates to the 2.24 version of GLib, in a format
154* that can be used by the C pre-processor.
155*
156* Since: 2.32
157*/
158#define GLIB_VERSION_2_24 (G_ENCODE_VERSION (2, 24))
159/**
160* GLIB_VERSION_2_26:
161*
162* A macro that evaluates to the 2.26 version of GLib, in a format
163* that can be used by the C pre-processor.
164*
165* Since: 2.32
166*/
167#define GLIB_VERSION_2_26 (G_ENCODE_VERSION (2, 26))
168/**
169* GLIB_VERSION_2_28:
170*
171* A macro that evaluates to the 2.28 version of GLib, in a format
172* that can be used by the C pre-processor.
173*
174* Since: 2.32
175*/
176#define GLIB_VERSION_2_28 (G_ENCODE_VERSION (2, 28))
177/**
178* GLIB_VERSION_2_30:
179*
180* A macro that evaluates to the 2.30 version of GLib, in a format
181* that can be used by the C pre-processor.
182*
183* Since: 2.32
184*/
185#define GLIB_VERSION_2_30 (G_ENCODE_VERSION (2, 30))
186/**
187* GLIB_VERSION_2_32:
188*
189* A macro that evaluates to the 2.32 version of GLib, in a format
190* that can be used by the C pre-processor.
191*
192* Since: 2.32
193*/
194#define GLIB_VERSION_2_32 (G_ENCODE_VERSION (2, 32))
195/**
196* GLIB_VERSION_2_34:
197*
198* A macro that evaluates to the 2.34 version of GLib, in a format
199* that can be used by the C pre-processor.
200*
201* Since: 2.34
202*/
203#define GLIB_VERSION_2_34 (G_ENCODE_VERSION (2, 34))
204/**
205* GLIB_VERSION_2_36:
206*
207* A macro that evaluates to the 2.36 version of GLib, in a format
208* that can be used by the C pre-processor.
209*
210* Since: 2.36
211*/
212#define GLIB_VERSION_2_36 (G_ENCODE_VERSION (2, 36))
213/**
214* GLIB_VERSION_2_38:
215*
216* A macro that evaluates to the 2.38 version of GLib, in a format
217* that can be used by the C pre-processor.
218*
219* Since: 2.38
220*/
221#define GLIB_VERSION_2_38 (G_ENCODE_VERSION (2, 38))
222/**
223* GLIB_VERSION_2_40:
224*
225* A macro that evaluates to the 2.40 version of GLib, in a format
226* that can be used by the C pre-processor.
227*
228* Since: 2.40
229*/
230#define GLIB_VERSION_2_40 (G_ENCODE_VERSION (2, 40))
231/**
232* GLIB_VERSION_2_42:
233*
234* A macro that evaluates to the 2.42 version of GLib, in a format
235* that can be used by the C pre-processor.
236*
237* Since: 2.42
238*/
239#define GLIB_VERSION_2_42 (G_ENCODE_VERSION (2, 42))
240/**
241* GLIB_VERSION_2_44:
242*
243* A macro that evaluates to the 2.44 version of GLib, in a format
244* that can be used by the C pre-processor.
245*
246* Since: 2.44
247*/
248#define GLIB_VERSION_2_44 (G_ENCODE_VERSION (2, 44))
249/**
250* GLIB_VERSION_2_46:
251*
252* A macro that evaluates to the 2.46 version of GLib, in a format
253* that can be used by the C pre-processor.
254*
255* Since: 2.46
256*/
257#define GLIB_VERSION_2_46 (G_ENCODE_VERSION (2, 46))
258/**
259* GLIB_VERSION_2_48:
260*
261* A macro that evaluates to the 2.48 version of GLib, in a format
262* that can be used by the C pre-processor.
263*
264* Since: 2.48
265*/
266#define GLIB_VERSION_2_48 (G_ENCODE_VERSION (2, 48))
267/**
268* GLIB_VERSION_2_50:
269*
270* A macro that evaluates to the 2.50 version of GLib, in a format
271* that can be used by the C pre-processor.
272*
273* Since: 2.50
274*/
275#define GLIB_VERSION_2_50 (G_ENCODE_VERSION (2, 50))
276/**
277* GLIB_VERSION_2_52:
278*
279* A macro that evaluates to the 2.52 version of GLib, in a format
280* that can be used by the C pre-processor.
281*
282* Since: 2.52
283*/
284#define GLIB_VERSION_2_52 (G_ENCODE_VERSION (2, 52))
285/**
286* GLIB_VERSION_2_54:
287*
288* A macro that evaluates to the 2.54 version of GLib, in a format
289* that can be used by the C pre-processor.
290*
291* Since: 2.54
292*/
293#define GLIB_VERSION_2_54 (G_ENCODE_VERSION (2, 54))
294/**
295* GLIB_VERSION_2_56:
296*
297* A macro that evaluates to the 2.56 version of GLib, in a format
298* that can be used by the C pre-processor.
299*
300* Since: 2.56
301*/
302#define GLIB_VERSION_2_56 (G_ENCODE_VERSION (2, 56))
303/**
304* GLIB_VERSION_2_58:
305*
306* A macro that evaluates to the 2.58 version of GLib, in a format
307* that can be used by the C pre-processor.
308*
309* Since: 2.58
310*/
311#define GLIB_VERSION_2_58 (G_ENCODE_VERSION (2, 58))
312/**
313* GLIB_VERSION_2_60:
314*
315* A macro that evaluates to the 2.60 version of GLib, in a format
316* that can be used by the C pre-processor.
317*
318* Since: 2.60
319*/
320#define GLIB_VERSION_2_60 (G_ENCODE_VERSION (2, 60))
321/**
322* GLIB_VERSION_2_62:
323*
324* A macro that evaluates to the 2.62 version of GLib, in a format
325* that can be used by the C pre-processor.
326*
327* Since: 2.62
328*/
329#define GLIB_VERSION_2_62 (G_ENCODE_VERSION (2, 62))
330/**
331* GLIB_VERSION_2_64:
332*
333* A macro that evaluates to the 2.64 version of GLib, in a format
334* that can be used by the C pre-processor.
335*
336* Since: 2.64
337*/
338#define GLIB_VERSION_2_64 (G_ENCODE_VERSION (2, 64))
339/**
340* GLIB_VERSION_2_66:
341*
342* A macro that evaluates to the 2.66 version of GLib, in a format
343* that can be used by the C pre-processor.
344*
345* Since: 2.66
346*/
347#define GLIB_VERSION_2_66 (G_ENCODE_VERSION (2, 66))
348/**
349* GLIB_VERSION_2_68:
350*
351* A macro that evaluates to the 2.68 version of GLib, in a format
352* that can be used by the C pre-processor.
353*
354* Since: 2.68
355*/
356#define GLIB_VERSION_2_68 (G_ENCODE_VERSION (2, 68))
357/**
358* GLIB_VERSION_2_70:
359*
360* A macro that evaluates to the 2.70 version of GLib, in a format
361* that can be used by the C pre-processor.
362*
363* Since: 2.70
364*/
365#define GLIB_VERSION_2_70 (G_ENCODE_VERSION (2, 70))
366/**
367* GLIB_VERSION_2_72:
368*
369* A macro that evaluates to the 2.72 version of GLib, in a format
370* that can be used by the C pre-processor.
371*
372* Since: 2.72
373*/
374#define GLIB_VERSION_2_72 (G_ENCODE_VERSION (2, 72))
375/**
376* GLIB_VERSION_2_74:
377*
378* A macro that evaluates to the 2.74 version of GLib, in a format
379* that can be used by the C pre-processor.
380*
381* Since: 2.74
382*/
383#define GLIB_VERSION_2_74 (G_ENCODE_VERSION (2, 74))
384/**
385* GLIB_VERSION_2_76:
386*
387* A macro that evaluates to the 2.76 version of GLib, in a format
388* that can be used by the C pre-processor.
389*
390* Since: 2.76
391*/
392#define GLIB_VERSION_2_76 (G_ENCODE_VERSION (2, 76))
393/**
394* GLIB_VERSION_2_78:
395*
396* A macro that evaluates to the 2.78 version of GLib, in a format
397* that can be used by the C pre-processor.
398*
399* Since: 2.78
400*/
401#define GLIB_VERSION_2_78 (G_ENCODE_VERSION (2, 78))
402/**
403* GLIB_VERSION_2_80:
404*
405* A macro that evaluates to the 2.80 version of GLib, in a format
406* that can be used by the C pre-processor.
407*
408* Since: 2.80
409*/
410#define GLIB_VERSION_2_80 (G_ENCODE_VERSION (2, 80))
411/**
412* GLIB_VERSION_2_82:
413*
414* A macro that evaluates to the 2.82 version of GLib, in a format
415* that can be used by the C pre-processor.
416*
417* Since: 2.82
418*/
419#define GLIB_VERSION_2_82 (G_ENCODE_VERSION (2, 82))
420/**
421* GLIB_VERSION_2_84:
422*
423* A macro that evaluates to the 2.84 version of GLib, in a format
424* that can be used by the C pre-processor.
425*
426* Since: 2.84
427*/
428#define GLIB_VERSION_2_84 (G_ENCODE_VERSION (2, 84))
429/**
430* GLIB_VERSION_2_86:
431*
432* A macro that evaluates to the 2.86 version of GLib, in a format
433* that can be used by the C pre-processor.
434*
435* Since: 2.86
436*/
437#define GLIB_VERSION_2_86 (G_ENCODE_VERSION (2, 86))
438/**
439* GLIB_VERSION_2_88:
440*
441* A macro that evaluates to the 2.88 version of GLib, in a format
442* that can be used by the C pre-processor.
443*
444* Since: 2.88
445*/
446#define GLIB_VERSION_2_88 (G_ENCODE_VERSION (2, 88))
447
448/**
449 * GLIB_VERSION_CUR_STABLE:
450 *
451 * A macro that evaluates to the current stable version of GLib, in a format
452 * that can be used by the C pre-processor.
453 *
454 * During an unstable development cycle, this evaluates to the next stable
455 * (unreleased) version which will be the result of the development cycle.
456 *
457 * Since: 2.32
458 */
459#if (GLIB_MINOR_VERSION % 2)
460#define GLIB_VERSION_CUR_STABLE (G_ENCODE_VERSION (GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION + 1))
461#else
462#define GLIB_VERSION_CUR_STABLE (G_ENCODE_VERSION (GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION))
463#endif
464
465/**
466 * GLIB_VERSION_PREV_STABLE:
467 *
468 * A macro that evaluates to the previous stable version of GLib, in a format
469 * that can be used by the C pre-processor.
470 *
471 * During an unstable development cycle, this evaluates to the most recent
472 * released stable release, which preceded this development cycle.
473 *
474 * Since: 2.32
475 */
476#if (GLIB_MINOR_VERSION % 2)
477#define GLIB_VERSION_PREV_STABLE (G_ENCODE_VERSION (GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION - 1))
478#else
479#define GLIB_VERSION_PREV_STABLE (G_ENCODE_VERSION (GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION - 2))
480#endif
481
482/**
483 * GLIB_VERSION_MIN_REQUIRED:
484 *
485 * A macro that should be defined by the user prior to including
486 * the glib.h header.
487 * The definition should be one of the predefined GLib version
488 * macros: %GLIB_VERSION_2_26, %GLIB_VERSION_2_28,...
489 *
490 * This macro defines the earliest version of GLib that the package is
491 * required to be able to compile against.
492 *
493 * If the compiler is configured to warn about the use of deprecated
494 * functions, then using functions that were deprecated in version
495 * %GLIB_VERSION_MIN_REQUIRED or earlier will cause warnings (but
496 * using functions deprecated in later releases will not).
497 *
498 * Since: 2.32
499 */
500/* If the package sets GLIB_VERSION_MIN_REQUIRED to some future
501 * GLIB_VERSION_X_Y value that we don't know about, it will compare as
502 * 0 in preprocessor tests.
503 */
504#ifndef GLIB_VERSION_MIN_REQUIRED
505#define GLIB_VERSION_MIN_REQUIRED (GLIB_VERSION_CUR_STABLE)
506#elif GLIB_VERSION_MIN_REQUIRED == 0
507#undef GLIB_VERSION_MIN_REQUIRED
508#define GLIB_VERSION_MIN_REQUIRED (GLIB_VERSION_CUR_STABLE + 2)
509#endif
510
511/**
512 * GLIB_VERSION_MAX_ALLOWED:
513 *
514 * A macro that should be defined by the user prior to including
515 * the glib.h header.
516 * The definition should be one of the predefined GLib version
517 * macros: %GLIB_VERSION_2_26, %GLIB_VERSION_2_28,...
518 *
519 * This macro defines the latest version of the GLib API that the
520 * package is allowed to make use of.
521 *
522 * If the compiler is configured to warn about the use of deprecated
523 * functions, then using functions added after version
524 * %GLIB_VERSION_MAX_ALLOWED will cause warnings.
525 *
526 * Unless you are using GLIB_CHECK_VERSION() or the like to compile
527 * different code depending on the GLib version, then this should be
528 * set to the same value as %GLIB_VERSION_MIN_REQUIRED.
529 *
530 * Since: 2.32
531 */
532#if !defined(GLIB_VERSION_MAX_ALLOWED) || (GLIB_VERSION_MAX_ALLOWED == 0)
533#undef GLIB_VERSION_MAX_ALLOWED
534#define GLIB_VERSION_MAX_ALLOWED (GLIB_VERSION_CUR_STABLE)
535#endif
536
537/* sanity checks */
538#if GLIB_VERSION_MIN_REQUIRED > GLIB_VERSION_CUR_STABLE
539#error "GLIB_VERSION_MIN_REQUIRED must be <= GLIB_VERSION_CUR_STABLE"
540#endif
541#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_MIN_REQUIRED
542#error "GLIB_VERSION_MAX_ALLOWED must be >= GLIB_VERSION_MIN_REQUIRED"
543#endif
544#if GLIB_VERSION_MIN_REQUIRED < GLIB_VERSION_2_26
545#error "GLIB_VERSION_MIN_REQUIRED must be >= GLIB_VERSION_2_26"
546#endif
547
548#endif /* __G_VERSION_MACROS_H__ */
549