1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2 3 /* Copyright (C) 2019-2021 Hans Petter Jansson 4 * 5 * This file is part of Chafa, a program that turns images into character art. 6 * 7 * Chafa is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU Lesser General Public License as published 9 * by the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * Chafa is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public License 18 * along with Chafa. If not, see <http://www.gnu.org/licenses/>. */ 19 20 #ifndef __CHAFA_VERSION_MACROS_H__ 21 #define __CHAFA_VERSION_MACROS_H__ 22 23 #if !defined (__CHAFA_H_INSIDE__) && !defined (CHAFA_COMPILATION) 24 # error "Only <chafa.h> can be included directly." 25 #endif 26 27 /* Our current version is defined here */ 28 #include <chafaconfig.h> 29 30 G_BEGIN_DECLS 31 32 /* Exported symbol versioning/visibility. Similar to the versioning macros 33 * used by GLib. */ 34 35 #define CHAFA_VERSION_1_0 (G_ENCODE_VERSION (1, 0)) 36 #define CHAFA_VERSION_1_2 (G_ENCODE_VERSION (1, 2)) 37 #define CHAFA_VERSION_1_4 (G_ENCODE_VERSION (1, 4)) 38 #define CHAFA_VERSION_1_6 (G_ENCODE_VERSION (1, 6)) 39 #define CHAFA_VERSION_1_8 (G_ENCODE_VERSION (1, 8)) 40 #define CHAFA_VERSION_1_10 (G_ENCODE_VERSION (1, 10)) 41 42 /* Evaluates to the current stable version; for development cycles, 43 * this means the next stable target. */ 44 #if (CHAFA_MINOR_VERSION % 2) 45 #define CHAFA_VERSION_CUR_STABLE (G_ENCODE_VERSION (CHAFA_MAJOR_VERSION, CHAFA_MINOR_VERSION + 1)) 46 #else 47 #define CHAFA_VERSION_CUR_STABLE (G_ENCODE_VERSION (CHAFA_MAJOR_VERSION, CHAFA_MINOR_VERSION)) 48 #endif 49 50 /* Evaluates to the previous stable version */ 51 #if (CHAFA_MINOR_VERSION % 2) 52 #define CHAFA_VERSION_PREV_STABLE (G_ENCODE_VERSION (CHAFA_MAJOR_VERSION, CHAFA_MINOR_VERSION - 1)) 53 #else 54 #define CHAFA_VERSION_PREV_STABLE (G_ENCODE_VERSION (CHAFA_MAJOR_VERSION, CHAFA_MINOR_VERSION - 2)) 55 #endif 56 57 /** 58 * CHAFA_VERSION_MIN_REQUIRED: 59 * 60 * A macro that can be defined by the user prior to including 61 * the chafa.h header. 62 * The definition should be one of the predefined Chafa version 63 * macros: %CHAFA_VERSION_1_0, %CHAFA_VERSION_1_2,... 64 * 65 * This macro defines the earliest version of Chafa that the package is 66 * required to be able to compile against. 67 * 68 * If the compiler is configured to warn about the use of deprecated 69 * functions, then using functions that were deprecated in version 70 * %CHAFA_VERSION_MIN_REQUIRED or earlier will cause warnings (but 71 * using functions deprecated in later releases will not). 72 * 73 * Since: 1.2 74 */ 75 76 /* Make sure all exportable symbols are made visible, even 77 * deprecated ones. */ 78 #ifdef CHAFA_COMPILATION 79 # define CHAFA_VERSION_MIN_REQUIRED (CHAFA_VERSION_1_0) 80 #endif 81 82 /* If the package sets CHAFA_VERSION_MIN_REQUIRED to some future 83 * CHAFA_VERSION_X_Y value that we don't know about, it will compare as 84 * 0 in preprocessor tests. */ 85 #ifndef CHAFA_VERSION_MIN_REQUIRED 86 # define CHAFA_VERSION_MIN_REQUIRED (CHAFA_VERSION_CUR_STABLE) 87 #elif CHAFA_VERSION_MIN_REQUIRED == 0 88 # undef CHAFA_VERSION_MIN_REQUIRED 89 # define CHAFA_VERSION_MIN_REQUIRED (CHAFA_VERSION_CUR_STABLE + 2) 90 #endif 91 92 /** 93 * CHAFA_VERSION_MAX_ALLOWED: 94 * 95 * A macro that can be defined by the user prior to including 96 * the chafa.h header. 97 * The definition should be one of the predefined Chafa version 98 * macros: %CHAFA_VERSION_1_0, %CHAFA_VERSION_1_2,... 99 * 100 * This macro defines the latest version of the Chafa API that the 101 * package is allowed to make use of. 102 * 103 * If the compiler is configured to warn about the use of deprecated 104 * functions, then using functions added after version 105 * %CHAFA_VERSION_MAX_ALLOWED will cause warnings. 106 * 107 * This should normally be set to the same value as 108 * %CHAFA_VERSION_MIN_REQUIRED. 109 * 110 * Since: 1.2 111 */ 112 #if !defined (CHAFA_VERSION_MAX_ALLOWED) || (CHAFA_VERSION_MAX_ALLOWED == 0) 113 # undef CHAFA_VERSION_MAX_ALLOWED 114 # define CHAFA_VERSION_MAX_ALLOWED (CHAFA_VERSION_CUR_STABLE) 115 #endif 116 117 /* Sanity checks */ 118 #if CHAFA_VERSION_MIN_REQUIRED > CHAFA_VERSION_CUR_STABLE 119 #error "CHAFA_VERSION_MIN_REQUIRED must be <= CHAFA_VERSION_CUR_STABLE" 120 #endif 121 #if CHAFA_VERSION_MAX_ALLOWED < CHAFA_VERSION_MIN_REQUIRED 122 #error "CHAFA_VERSION_MAX_ALLOWED must be >= CHAFA_VERSION_MIN_REQUIRED" 123 #endif 124 #if CHAFA_VERSION_MIN_REQUIRED < CHAFA_VERSION_1_0 125 #error "CHAFA_VERSION_MIN_REQUIRED must be >= CHAFA_VERSION_1_0" 126 #endif 127 128 #ifndef _CHAFA_EXTERN 129 # define _CHAFA_EXTERN extern 130 #endif 131 132 #define CHAFA_AVAILABLE_IN_ALL _CHAFA_EXTERN 133 134 #if CHAFA_VERSION_MIN_REQUIRED >= CHAFA_VERSION_1_2 135 # define CHAFA_DEPRECATED_IN_1_2 G_DEPRECATED 136 # define CHAFA_DEPRECATED_IN_1_2_FOR(f) G_DEPRECATED_FOR(f) 137 #else 138 # define CHAFA_DEPRECATED_IN_1_2 _CHAFA_EXTERN 139 # define CHAFA_DEPRECATED_IN_1_2_FOR(f) _CHAFA_EXTERN 140 #endif 141 142 #if CHAFA_VERSION_MAX_ALLOWED < CHAFA_VERSION_1_2 143 # define CHAFA_AVAILABLE_IN_1_2 G_UNAVAILABLE(1, 2) 144 #else 145 # define CHAFA_AVAILABLE_IN_1_2 _CHAFA_EXTERN 146 #endif 147 148 #if CHAFA_VERSION_MIN_REQUIRED >= CHAFA_VERSION_1_4 149 # define CHAFA_DEPRECATED_IN_1_4 G_DEPRECATED 150 # define CHAFA_DEPRECATED_IN_1_4_FOR(f) G_DEPRECATED_FOR(f) 151 #else 152 # define CHAFA_DEPRECATED_IN_1_4 _CHAFA_EXTERN 153 # define CHAFA_DEPRECATED_IN_1_4_FOR(f) _CHAFA_EXTERN 154 #endif 155 156 #if CHAFA_VERSION_MAX_ALLOWED < CHAFA_VERSION_1_4 157 # define CHAFA_AVAILABLE_IN_1_4 G_UNAVAILABLE(1, 4) 158 #else 159 # define CHAFA_AVAILABLE_IN_1_4 _CHAFA_EXTERN 160 #endif 161 162 #if CHAFA_VERSION_MIN_REQUIRED >= CHAFA_VERSION_1_6 163 # define CHAFA_DEPRECATED_IN_1_6 G_DEPRECATED 164 # define CHAFA_DEPRECATED_IN_1_6_FOR(f) G_DEPRECATED_FOR(f) 165 #else 166 # define CHAFA_DEPRECATED_IN_1_6 _CHAFA_EXTERN 167 # define CHAFA_DEPRECATED_IN_1_6_FOR(f) _CHAFA_EXTERN 168 #endif 169 170 #if CHAFA_VERSION_MAX_ALLOWED < CHAFA_VERSION_1_6 171 # define CHAFA_AVAILABLE_IN_1_6 G_UNAVAILABLE(1, 6) 172 #else 173 # define CHAFA_AVAILABLE_IN_1_6 _CHAFA_EXTERN 174 #endif 175 176 #if CHAFA_VERSION_MIN_REQUIRED >= CHAFA_VERSION_1_8 177 # define CHAFA_DEPRECATED_IN_1_8 G_DEPRECATED 178 # define CHAFA_DEPRECATED_IN_1_8_FOR(f) G_DEPRECATED_FOR(f) 179 #else 180 # define CHAFA_DEPRECATED_IN_1_8 _CHAFA_EXTERN 181 # define CHAFA_DEPRECATED_IN_1_8_FOR(f) _CHAFA_EXTERN 182 #endif 183 184 #if CHAFA_VERSION_MAX_ALLOWED < CHAFA_VERSION_1_8 185 # define CHAFA_AVAILABLE_IN_1_8 G_UNAVAILABLE(1, 8) 186 #else 187 # define CHAFA_AVAILABLE_IN_1_8 _CHAFA_EXTERN 188 #endif 189 190 #if CHAFA_VERSION_MIN_REQUIRED >= CHAFA_VERSION_1_10 191 # define CHAFA_DEPRECATED_IN_1_10 G_DEPRECATED 192 # define CHAFA_DEPRECATED_IN_1_10_FOR(f) G_DEPRECATED_FOR(f) 193 #else 194 # define CHAFA_DEPRECATED_IN_1_10 _CHAFA_EXTERN 195 # define CHAFA_DEPRECATED_IN_1_10_FOR(f) _CHAFA_EXTERN 196 #endif 197 198 #if CHAFA_VERSION_MAX_ALLOWED < CHAFA_VERSION_1_10 199 # define CHAFA_AVAILABLE_IN_1_10 G_UNAVAILABLE(1, 10) 200 #else 201 # define CHAFA_AVAILABLE_IN_1_10 _CHAFA_EXTERN 202 #endif 203 204 G_END_DECLS 205 206 #endif /* __CHAFA_VERSION_MACROS_H__ */ 207