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