]> Pileus Git - ~andy/gtk/blob - gdk/gdkversionmacros.h.in
gdk: Add deprecation/availability macros for 3.6
[~andy/gtk] / gdk / gdkversionmacros.h.in
1 /* gdkversionmacros.h - version boundaries checks
2  * Copyright (C) 2012 Red Hat, Inc.
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 #if !defined (__GDK_H_INSIDE__) && !defined (GDK_COMPILATION)
21 #error "Only <gdk/gdk.h> can be included directly."
22 #endif
23
24 #ifndef __GDK_VERSION_MACROS_H__
25 #define __GDK_VERSION_MACROS_H__
26
27 #include <glib.h>
28
29 #define GDK_MAJOR_VERSION (@GTK_MAJOR_VERSION@)
30 #define GDK_MINOR_VERSION (@GTK_MINOR_VERSION@)
31 #define GDK_MICRO_VERSION (@GTK_MICRO_VERSION@)
32
33 /**
34  * GDK_DISABLE_DEPRECATION_WARNINGS:
35  *
36  * A macro that should be defined before including the gdk.h header.
37  * If it is defined, no compiler warnings will be produced for uses
38  * of deprecated GDK and GTK+ APIs.
39  */
40
41 #ifdef GDK_DISABLE_DEPRECATION_WARNINGS
42 #define GDK_DEPRECATED
43 #define GDK_DEPRECATED_FOR(f)
44 #define GDK_UNAVAILABLE(maj,min)
45 #else
46 #define GDK_DEPRECATED G_DEPRECATED
47 #define GDK_DEPRECATED_FOR(f) G_DEPRECATED_FOR(f)
48 #define GDK_UNAVAILABLE(maj,min) G_UNAVAILABLE(maj,min)
49 #endif
50
51 /* XXX: Every new stable minor release bump should add a macro here */
52
53 /**
54  * GDK_VERSION_3_0:
55  *
56  * A macro that evaluates to the 3.0 version of GDK, in a format
57  * that can be used by the C pre-processor.
58  *
59  * Since: 3.4
60  */
61 #define GDK_VERSION_3_0         (G_ENCODE_VERSION (3, 0))
62
63 /**
64  * GDK_VERSION_3_2:
65  *
66  * A macro that evaluates to the 3.2 version of GDK, in a format
67  * that can be used by the C pre-processor.
68  *
69  * Since: 3.4
70  */
71 #define GDK_VERSION_3_2         (G_ENCODE_VERSION (3, 2))
72
73 /**
74  * GDK_VERSION_3_4:
75  *
76  * A macro that evaluates to the 3.4 version of GDK, in a format
77  * that can be used by the C pre-processor.
78  *
79  * Since: 3.4
80  */
81 #define GDK_VERSION_3_4         (G_ENCODE_VERSION (3, 4))
82
83
84 /* evaluates to the current stable version; for development cycles,
85  * this means the next stable target
86  */
87 #if (GDK_MINOR_VERSION % 2)
88 #define GDK_VERSION_CUR_STABLE         (G_ENCODE_VERSION (GDK_MAJOR_VERSION, GDK_MINOR_VERSION + 1))
89 #else
90 #define GDK_VERSION_CUR_STABLE         (G_ENCODE_VERSION (GDK_MAJOR_VERSION, GDK_MINOR_VERSION))
91 #endif
92
93 /* evaluates to the previous stable version */
94 #if (GDK_MINOR_VERSION % 2)
95 #define GDK_VERSION_PREV_STABLE        (G_ENCODE_VERSION (GDK_MAJOR_VERSION, GDK_MINOR_VERSION - 1))
96 #else
97 #define GDK_VERSION_PREV_STABLE        (G_ENCODE_VERSION (GDK_MAJOR_VERSION, GDK_MINOR_VERSION - 2))
98 #endif
99
100 /**
101  * GDK_VERSION_MIN_REQUIRED:
102  *
103  * A macro that should be defined by the user prior to including
104  * the gdk.h header.
105  * The definition should be one of the predefined GDK version
106  * macros: %GDK_VERSION_3_0, %GDK_VERSION_3_2,...
107  *
108  * This macro defines the lower bound for the GLib API to use.
109  *
110  * If a function has been deprecated in a newer version of GDK,
111  * it is possible to use this symbol to avoid the compiler warnings
112  * without disabling warning for every deprecated function.
113  *
114  * Since: 3.4
115  */
116 #ifndef GDK_VERSION_MIN_REQUIRED
117 # define GDK_VERSION_MIN_REQUIRED      (GDK_VERSION_PREV_STABLE)
118 #endif
119
120 /**
121  * GDK_VERSION_MAX_ALLOWED:
122  *
123  * A macro that should be defined by the user prior to including
124  * the gdk.h header.
125  * The definition should be one of the predefined GDK version
126  * macros: %GDK_VERSION_3_0, %GDK_VERSION_3_2,...
127  *
128  * This macro defines the upper bound for the GDK API to use.
129  *
130  * If a function has been introduced in a newer version of GDK,
131  * it is possible to use this symbol to get compiler warnings when
132  * trying to use that function.
133  *
134  * Since: 3.4
135  */
136 #ifndef GDK_VERSION_MAX_ALLOWED
137 # if GDK_VERSION_MIN_REQUIRED > GDK_VERSION_PREV_STABLE
138 #  define GDK_VERSION_MAX_ALLOWED      GDK_VERSION_MIN_REQUIRED
139 # else
140 #  define GDK_VERSION_MAX_ALLOWED      GDK_VERSION_CUR_STABLE
141 # endif
142 #endif
143
144 /* sanity checks */
145 #if GDK_VERSION_MAX_ALLOWED < GDK_VERSION_MIN_REQUIRED
146 #error "GDK_VERSION_MAX_ALLOWED must be >= GDK_VERSION_MIN_REQUIRED"
147 #endif
148 #if GDK_VERSION_MIN_REQUIRED < GDK_VERSION_3_0
149 #error "GDK_VERSION_MIN_REQUIRED must be >= GDK_VERSION_3_0"
150 #endif
151
152 /* XXX: Every new stable minor release should add a set of macros here */
153
154 #if GDK_VERSION_MIN_REQUIRED >= GDK_VERSION_3_0
155 # define GDK_DEPRECATED_IN_3_0                GDK_DEPRECATED
156 # define GDK_DEPRECATED_IN_3_0_FOR(f)         GDK_DEPRECATED_FOR(f)
157 #else
158 # define GDK_DEPRECATED_IN_3_0
159 # define GDK_DEPRECATED_IN_3_0_FOR(f)
160 #endif
161
162 #if GDK_VERSION_MAX_ALLOWED < GDK_VERSION_3_0
163 # define GDK_AVAILABLE_IN_3_0                 GDK_UNAVAILABLE(3, 0)
164 #else
165 # define GDK_AVAILABLE_IN_3_0
166 #endif
167
168 #if GDK_VERSION_MIN_REQUIRED >= GDK_VERSION_3_2
169 # define GDK_DEPRECATED_IN_3_2                GDK_DEPRECATED
170 # define GDK_DEPRECATED_IN_3_2_FOR(f)         GDK_DEPRECATED_FOR(f)
171 #else
172 # define GDK_DEPRECATED_IN_3_2
173 # define GDK_DEPRECATED_IN_3_2_FOR(f)
174 #endif
175
176 #if GDK_VERSION_MAX_ALLOWED < GDK_VERSION_3_2
177 # define GDK_AVAILABLE_IN_3_2                 GDK_UNAVAILABLE(3, 2)
178 #else
179 # define GDK_AVAILABLE_IN_3_2
180 #endif
181
182 #if GDK_VERSION_MIN_REQUIRED >= GDK_VERSION_3_4
183 # define GDK_DEPRECATED_IN_3_4                GDK_DEPRECATED
184 # define GDK_DEPRECATED_IN_3_4_FOR(f)         GDK_DEPRECATED_FOR(f)
185 #else
186 # define GDK_DEPRECATED_IN_3_4
187 # define GDK_DEPRECATED_IN_3_4_FOR(f)
188 #endif
189
190 #if GDK_VERSION_MAX_ALLOWED < GDK_VERSION_3_4
191 # define GDK_AVAILABLE_IN_3_4                 GDK_UNAVAILABLE(3, 4)
192 #else
193 # define GDK_AVAILABLE_IN_3_4
194 #endif
195
196 #if GDK_VERSION_MIN_REQUIRED >= GDK_VERSION_3_6
197 # define GDK_DEPRECATED_IN_3_6                GDK_DEPRECATED
198 # define GDK_DEPRECATED_IN_3_6_FOR(f)         GDK_DEPRECATED_FOR(f)
199 #else
200 # define GDK_DEPRECATED_IN_3_6
201 # define GDK_DEPRECATED_IN_3_6_FOR(f)
202 #endif
203
204 #if GDK_VERSION_MAX_ALLOWED < GDK_VERSION_3_6
205 # define GDK_AVAILABLE_IN_3_6                 GDK_UNAVAILABLE(3, 6)
206 #else
207 # define GDK_AVAILABLE_IN_3_6
208 #endif
209
210 #endif  /* __GDK_VERSION_MACROS_H__ */