Debian Codegraph @

src/dex-version.h.in

raw
1 /* dex-version.h.in
2 *
3 * Copyright 2022 Christian Hergert
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 *
19 * SPDX-License-Identifier: LGPL-2.1-or-later
20 */
21
22 #pragma once
23
24 #if !defined(DEX_INSIDE) && !defined(DEX_COMPILATION)
25 # error "Only <libdex.h> can be included directly."
26 #endif
27
28 /**
29 * SECTION:libdexversion
30 * @short_description: libdex version checking
31 *
32 * libdex provides macros to check the version of the library
33 * at compile-time
34 */
35
36 /**
37 * DEX_MAJOR_VERSION:
38 *
39 * libdex major version component (e.g. 1 if %DEX_VERSION is 1.2.3)
40 */
41 #define DEX_MAJOR_VERSION (@MAJOR_VERSION@)
42
43 /**
44 * DEX_MINOR_VERSION:
45 *
46 * libdex minor version component (e.g. 2 if %DEX_VERSION is 1.2.3)
47 */
48 #define DEX_MINOR_VERSION (@MINOR_VERSION@)
49
50 /**
51 * DEX_MICRO_VERSION:
52 *
53 * libdex micro version component (e.g. 3 if %DEX_VERSION is 1.2.3)
54 */
55 #define DEX_MICRO_VERSION (@MICRO_VERSION@)
56
57 /**
58 * DEX_VERSION
59 *
60 * libdex version.
61 */
62 #define DEX_VERSION (@VERSION@)
63
64 /**
65 * DEX_VERSION_S:
66 *
67 * libdex version, encoded as a string, useful for printing and
68 * concatenation.
69 */
70 #define DEX_VERSION_S "@VERSION@"
71
72 #define DEX_ENCODE_VERSION(major,minor,micro) \
73 ((major) << 24 | (minor) << 16 | (micro) << 8)
74
75 /**
76 * DEX_VERSION_HEX:
77 *
78 * libdex version, encoded as an hexadecimal number, useful for
79 * integer comparisons.
80 */
81 #define DEX_VERSION_HEX \
82 (DEX_ENCODE_VERSION (DEX_MAJOR_VERSION, DEX_MINOR_VERSION, DEX_MICRO_VERSION))
83
84 /**
85 * DEX_CHECK_VERSION:
86 * @major: required major version
87 * @minor: required minor version
88 * @micro: required micro version
89 *
90 * Compile-time version checking. Evaluates to %TRUE if the version
91 * of libdex is greater than the required one.
92 */
93 #define DEX_CHECK_VERSION(major,minor,micro) \
94 (DEX_MAJOR_VERSION > (major) || \
95 (DEX_MAJOR_VERSION == (major) && DEX_MINOR_VERSION > (minor)) || \
96 (DEX_MAJOR_VERSION == (major) && DEX_MINOR_VERSION == (minor) && \
97 DEX_MICRO_VERSION >= (micro)))