Clarify the GLIB_VERSION_MIN_REQUIRED/MAX_ALLOWED docs
[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 earliest version of GLib that the package is
115  * required to be able to compile against.
116  *
117  * If the compiler is configured to warn about the use of deprecated
118  * functions, then using functions that were deprecated in version
119  * %GLIB_VERSION_MIN_REQUIRED or earlier will cause warnings (but
120  * using functions deprecated in later releases will not).
121  *
122  * Since: 2.32
123  */
124 /* If the package sets GLIB_VERSION_MIN_REQUIRED to some future
125  * GLIB_VERSION_X_Y value that we don't know about, it will compare as
126  * 0 in preprocessor tests.
127  */
128 #ifndef GLIB_VERSION_MIN_REQUIRED
129 # define GLIB_VERSION_MIN_REQUIRED      (GLIB_VERSION_CUR_STABLE)
130 #elif GLIB_VERSION_MIN_REQUIRED == 0
131 # undef  GLIB_VERSION_MIN_REQUIRED
132 # define GLIB_VERSION_MIN_REQUIRED      (GLIB_VERSION_CUR_STABLE + 2)
133 #endif
134
135 /**
136  * GLIB_VERSION_MAX_ALLOWED:
137  *
138  * A macro that should be defined by the user prior to including
139  * the glib.h header.
140  * The definition should be one of the predefined GLib version
141  * macros: %GLIB_VERSION_2_26, %GLIB_VERSION_2_28,...
142  *
143  * This macro defines the latest version of the GLib API that the
144  * package is allowed to make use of.
145  *
146  * If the compiler is configured to warn about the use of deprecated
147  * functions, then using functions added after version
148  * %GLIB_VERSION_MAX_ALLOWED will cause warnings.
149  *
150  * Unless you are using GLIB_CHECK_VERSION() or the like to compile
151  * different code depending on the GLib version, then this should be
152  * set to the same value as %GLIB_VERSION_MIN_REQUIRED.
153  *
154  * Since: 2.32
155  */
156 #if !defined (GLIB_VERSION_MAX_ALLOWED) || (GLIB_VERSION_MAX_ALLOWED == 0)
157 # undef GLIB_VERSION_MAX_ALLOWED
158 # define GLIB_VERSION_MAX_ALLOWED      (GLIB_VERSION_CUR_STABLE)
159 #endif
160
161 /* sanity checks */
162 #if GLIB_VERSION_MIN_REQUIRED > GLIB_VERSION_CUR_STABLE
163 #error "GLIB_VERSION_MIN_REQUIRED must be <= GLIB_VERSION_CUR_STABLE"
164 #endif
165 #if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_MIN_REQUIRED
166 #error "GLIB_VERSION_MAX_ALLOWED must be >= GLIB_VERSION_MIN_REQUIRED"
167 #endif
168 #if GLIB_VERSION_MIN_REQUIRED < GLIB_VERSION_2_26
169 #error "GLIB_VERSION_MIN_REQUIRED must be >= GLIB_VERSION_2_26"
170 #endif
171
172 /* These macros are used to mark deprecated functions in GLib headers,
173  * and thus have to be exposed in installed headers. But please
174  * do *not* use them in other projects. Instead, use G_DEPRECATED
175  * or define your own wrappers around it.
176  */
177
178 /* XXX: Every new stable minor release should add a set of macros here */
179
180 #if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_26
181 # define GLIB_DEPRECATED_IN_2_26                GLIB_DEPRECATED
182 # define GLIB_DEPRECATED_IN_2_26_FOR(f)         GLIB_DEPRECATED_FOR(f)
183 #else
184 # define GLIB_DEPRECATED_IN_2_26
185 # define GLIB_DEPRECATED_IN_2_26_FOR(f)
186 #endif
187
188 #if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_26
189 # define GLIB_AVAILABLE_IN_2_26                 GLIB_UNAVAILABLE(2, 26)
190 #else
191 # define GLIB_AVAILABLE_IN_2_26
192 #endif
193
194 #if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_28
195 # define GLIB_DEPRECATED_IN_2_28                GLIB_DEPRECATED
196 # define GLIB_DEPRECATED_IN_2_28_FOR(f)         GLIB_DEPRECATED_FOR(f)
197 #else
198 # define GLIB_DEPRECATED_IN_2_28
199 # define GLIB_DEPRECATED_IN_2_28_FOR(f)
200 #endif
201
202 #if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_28
203 # define GLIB_AVAILABLE_IN_2_28                 GLIB_UNAVAILABLE(2, 28)
204 #else
205 # define GLIB_AVAILABLE_IN_2_28
206 #endif
207
208 #if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_30
209 # define GLIB_DEPRECATED_IN_2_30                GLIB_DEPRECATED
210 # define GLIB_DEPRECATED_IN_2_30_FOR(f)         GLIB_DEPRECATED_FOR(f)
211 #else
212 # define GLIB_DEPRECATED_IN_2_30
213 # define GLIB_DEPRECATED_IN_2_30_FOR(f)
214 #endif
215
216 #if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_30
217 # define GLIB_AVAILABLE_IN_2_30                 GLIB_UNAVAILABLE(2, 30)
218 #else
219 # define GLIB_AVAILABLE_IN_2_30
220 #endif
221
222 #if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_32
223 # define GLIB_DEPRECATED_IN_2_32                GLIB_DEPRECATED
224 # define GLIB_DEPRECATED_IN_2_32_FOR(f)         GLIB_DEPRECATED_FOR(f)
225 #else
226 # define GLIB_DEPRECATED_IN_2_32
227 # define GLIB_DEPRECATED_IN_2_32_FOR(f)
228 #endif
229
230 #if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_32
231 # define GLIB_AVAILABLE_IN_2_32                 GLIB_UNAVAILABLE(2, 32)
232 #else
233 # define GLIB_AVAILABLE_IN_2_32
234 #endif
235
236 #if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_34
237 # define GLIB_DEPRECATED_IN_2_34                GLIB_DEPRECATED
238 # define GLIB_DEPRECATED_IN_2_34_FOR(f)         GLIB_DEPRECATED_FOR(f)
239 #else
240 # define GLIB_DEPRECATED_IN_2_34
241 # define GLIB_DEPRECATED_IN_2_34_FOR(f)
242 #endif
243
244 #if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_34
245 # define GLIB_AVAILABLE_IN_2_34                 GLIB_UNAVAILABLE(2, 34)
246 #else
247 # define GLIB_AVAILABLE_IN_2_34
248 #endif
249
250 #endif /*  __G_VERSION_MACROS_H__ */