Deal with GLIB_VERSION_MIN_REQUIRED/MAX_ALLOWED being a "future" value
[platform/upstream/glib.git] / glib / gversionmacros.h
1 /* GLIB - Library of useful routines for C programming
2  * Copyright (C) 1995-1997  Peter Mattis, Spencer Kimball and Josh MacDonald
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
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 #if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
28 #error "Only <glib.h> can be included directly."
29 #endif
30
31 #ifndef __G_VERSION_MACROS_H__
32 #define __G_VERSION_MACROS_H__
33
34 /* Version boundaries checks */
35
36 #define G_ENCODE_VERSION(major,minor)   ((major) << 16 | (minor) << 8)
37
38 /* XXX: Every new stable minor release bump should add a macro here */
39
40 /**
41  * GLIB_VERSION_2_26:
42  *
43  * A macro that evaluates to the 2.26 version of GLib, in a format
44  * that can be used by the C pre-processor.
45  *
46  * Since: 2.32
47  */
48 #define GLIB_VERSION_2_26       (G_ENCODE_VERSION (2, 26))
49
50 /**
51  * GLIB_VERSION_2_28:
52  *
53  * A macro that evaluates to the 2.28 version of GLib, in a format
54  * that can be used by the C pre-processor.
55  *
56  * Since: 2.32
57  */
58 #define GLIB_VERSION_2_28       (G_ENCODE_VERSION (2, 28))
59
60 /**
61  * GLIB_VERSION_2_30:
62  *
63  * A macro that evaluates to the 2.30 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_30       (G_ENCODE_VERSION (2, 30))
69
70 /**
71  * GLIB_VERSION_2_32:
72  *
73  * A macro that evaluates to the 2.32 version of GLib, in a format
74  * that can be used by the C pre-processor.
75  *
76  * Since: 2.32
77  */
78 #define GLIB_VERSION_2_32       (G_ENCODE_VERSION (2, 32))
79
80 /**
81  * GLIB_VERSION_2_34:
82  *
83  * A macro that evaluates to the 2.34 version of GLib, in a format
84  * that can be used by the C pre-processor.
85  *
86  * Since: 2.34
87  */
88 #define GLIB_VERSION_2_34       (G_ENCODE_VERSION (2, 34))
89
90 /* evaluates to the current stable version; for development cycles,
91  * this means the next stable target
92  */
93 #if (GLIB_MINOR_VERSION % 2)
94 #define GLIB_VERSION_CUR_STABLE         (G_ENCODE_VERSION (GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION + 1))
95 #else
96 #define GLIB_VERSION_CUR_STABLE         (G_ENCODE_VERSION (GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION))
97 #endif
98
99 /* evaluates to the previous stable version */
100 #if (GLIB_MINOR_VERSION % 2)
101 #define GLIB_VERSION_PREV_STABLE        (G_ENCODE_VERSION (GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION - 1))
102 #else
103 #define GLIB_VERSION_PREV_STABLE        (G_ENCODE_VERSION (GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION - 2))
104 #endif
105
106 /**
107  * GLIB_VERSION_MIN_REQUIRED:
108  *
109  * A macro that should be defined by the user prior to including
110  * the glib.h header.
111  * The definition should be one of the predefined GLib version
112  * macros: %GLIB_VERSION_2_26, %GLIB_VERSION_2_28,...
113  *
114  * This macro defines the lower bound for the GLib API to use.
115  *
116  * If a function has been deprecated in a newer version of GLib,
117  * it is possible to use this symbol to avoid the compiler warnings
118  * without disabling warning for every deprecated function.
119  *
120  * Since: 2.32
121  */
122 /* If the package sets GLIB_VERSION_MIN_REQUIRED to some future
123  * GLIB_VERSION_X_Y value that we don't know about, it will compare as
124  * 0 in preprocessor tests.
125  */
126 #ifndef GLIB_VERSION_MIN_REQUIRED
127 # define GLIB_VERSION_MIN_REQUIRED      (GLIB_VERSION_CUR_STABLE)
128 #elif GLIB_VERSION_MIN_REQUIRED == 0
129 # undef  GLIB_VERSION_MIN_REQUIRED
130 # define GLIB_VERSION_MIN_REQUIRED      (GLIB_VERSION_CUR_STABLE + 2)
131 #endif
132
133 /**
134  * GLIB_VERSION_MAX_ALLOWED:
135  *
136  * A macro that should be defined by the user prior to including
137  * the glib.h header.
138  * The definition should be one of the predefined GLib version
139  * macros: %GLIB_VERSION_2_26, %GLIB_VERSION_2_28,...
140  *
141  * This macro defines the upper bound for the GLib API to use.
142  *
143  * If a function has been introduced in a newer version of GLib,
144  * it is possible to use this symbol to get compiler warnings when
145  * trying to use that function.
146  *
147  * Since: 2.32
148  */
149 #if !defined (GLIB_VERSION_MAX_ALLOWED) || (GLIB_VERSION_MAX_ALLOWED == 0)
150 # undef GLIB_VERSION_MAX_ALLOWED
151 # define GLIB_VERSION_MAX_ALLOWED      (GLIB_VERSION_CUR_STABLE)
152 #endif
153
154 /* sanity checks */
155 #if GLIB_VERSION_MIN_REQUIRED > GLIB_VERSION_CUR_STABLE
156 #error "GLIB_VERSION_MIN_REQUIRED must be <= GLIB_VERSION_CUR_STABLE"
157 #endif
158 #if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_MIN_REQUIRED
159 #error "GLIB_VERSION_MAX_ALLOWED must be >= GLIB_VERSION_MIN_REQUIRED"
160 #endif
161 #if GLIB_VERSION_MIN_REQUIRED < GLIB_VERSION_2_26
162 #error "GLIB_VERSION_MIN_REQUIRED must be >= GLIB_VERSION_2_26"
163 #endif
164
165 /* These macros are used to mark deprecated functions in GLib headers,
166  * and thus have to be exposed in installed headers. But please
167  * do *not* use them in other projects. Instead, use G_DEPRECATED
168  * or define your own wrappers around it.
169  */
170
171 /* XXX: Every new stable minor release should add a set of macros here */
172
173 #if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_26
174 # define GLIB_DEPRECATED_IN_2_26                GLIB_DEPRECATED
175 # define GLIB_DEPRECATED_IN_2_26_FOR(f)         GLIB_DEPRECATED_FOR(f)
176 #else
177 # define GLIB_DEPRECATED_IN_2_26
178 # define GLIB_DEPRECATED_IN_2_26_FOR(f)
179 #endif
180
181 #if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_26
182 # define GLIB_AVAILABLE_IN_2_26                 GLIB_UNAVAILABLE(2, 26)
183 #else
184 # define GLIB_AVAILABLE_IN_2_26
185 #endif
186
187 #if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_28
188 # define GLIB_DEPRECATED_IN_2_28                GLIB_DEPRECATED
189 # define GLIB_DEPRECATED_IN_2_28_FOR(f)         GLIB_DEPRECATED_FOR(f)
190 #else
191 # define GLIB_DEPRECATED_IN_2_28
192 # define GLIB_DEPRECATED_IN_2_28_FOR(f)
193 #endif
194
195 #if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_28
196 # define GLIB_AVAILABLE_IN_2_28                 GLIB_UNAVAILABLE(2, 28)
197 #else
198 # define GLIB_AVAILABLE_IN_2_28
199 #endif
200
201 #if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_30
202 # define GLIB_DEPRECATED_IN_2_30                GLIB_DEPRECATED
203 # define GLIB_DEPRECATED_IN_2_30_FOR(f)         GLIB_DEPRECATED_FOR(f)
204 #else
205 # define GLIB_DEPRECATED_IN_2_30
206 # define GLIB_DEPRECATED_IN_2_30_FOR(f)
207 #endif
208
209 #if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_30
210 # define GLIB_AVAILABLE_IN_2_30                 GLIB_UNAVAILABLE(2, 30)
211 #else
212 # define GLIB_AVAILABLE_IN_2_30
213 #endif
214
215 #if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_32
216 # define GLIB_DEPRECATED_IN_2_32                GLIB_DEPRECATED
217 # define GLIB_DEPRECATED_IN_2_32_FOR(f)         GLIB_DEPRECATED_FOR(f)
218 #else
219 # define GLIB_DEPRECATED_IN_2_32
220 # define GLIB_DEPRECATED_IN_2_32_FOR(f)
221 #endif
222
223 #if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_32
224 # define GLIB_AVAILABLE_IN_2_32                 GLIB_UNAVAILABLE(2, 32)
225 #else
226 # define GLIB_AVAILABLE_IN_2_32
227 #endif
228
229 #if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_34
230 # define GLIB_DEPRECATED_IN_2_34                GLIB_DEPRECATED
231 # define GLIB_DEPRECATED_IN_2_34_FOR(f)         GLIB_DEPRECATED_FOR(f)
232 #else
233 # define GLIB_DEPRECATED_IN_2_34
234 # define GLIB_DEPRECATED_IN_2_34_FOR(f)
235 #endif
236
237 #if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_34
238 # define GLIB_AVAILABLE_IN_2_34                 GLIB_UNAVAILABLE(2, 34)
239 #else
240 # define GLIB_AVAILABLE_IN_2_34
241 #endif
242
243 #endif /*  __G_VERSION_MACROS_H__ */