1 /* GLIB - Library of useful routines for C programming
2 * Copyright (C) 1995-1998 Peter Mattis, Spencer Kimball and Josh MacDonald
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.1 of the License, or (at your option) any later version.
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.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
19 * Modified by the GLib Team and others 1997-2000. See the AUTHORS
20 * file for a list of people on the GLib Team. See the ChangeLog
21 * files for a list of changes. These files are distributed with
22 * GLib at ftp://ftp.gtk.org/pub/gtk/.
31 * @Title: Version Information
32 * @Short_description: variables and functions to check the GLib version
34 * GLib provides version information, primarily useful in configure
35 * checks for builds that have a configure script. Applications will
36 * not typically use the features described here.
38 * The GLib headers annotate deprecated APIs in a way that produces
39 * compiler warnings if these deprecated APIs are used. The warnings
40 * can be turned off by defining the macro %GLIB_DISABLE_DEPRECATION_WARNINGS
41 * before including the glib.h header.
43 * GLib also provides support for building applications against
44 * defined subsets of deprecated or new GLib APIs. Define the macro
45 * %GLIB_VERSION_MIN_REQUIRED to specify up to what version of GLib
46 * you want to receive warnings about deprecated APIs. Define the
47 * macro %GLIB_VERSION_MAX_ALLOWED to specify the newest version of
48 * GLib whose API you want to use.
54 * The major version of the GLib library.
56 * An integer variable exported from the library linked
57 * against at application run time.
63 * The major version number of the GLib library.
65 * Like #glib_major_version, but from the headers used at
66 * application compile time, rather than from the library
67 * linked against at application run time.
73 * The minor version number of the GLib library.
75 * An integer variable exported from the library linked
76 * against at application run time.
82 * The minor version number of the GLib library.
84 * Like #gtk_minor_version, but from the headers used at
85 * application compile time, rather than from the library
86 * linked against at application run time.
92 * The micro version number of the GLib library.
94 * An integer variable exported from the library linked
95 * against at application run time.
101 * The micro version number of the GLib library.
103 * Like #gtk_micro_version, but from the headers used at
104 * application compile time, rather than from the library
105 * linked against at application run time.
109 * GLIB_CHECK_VERSION:
110 * @major: the major version to check for
111 * @minor: the minor version to check for
112 * @micro: the micro version to check for
114 * Checks the version of the GLib library that is being compiled
115 * against. See glib_check_version() for a runtime check.
117 * Returns: %TRUE if the version of the GLib header files
118 * is the same as or newer than the passed-in version.
124 * The binary age of the GLib library.
125 * Defines how far back backwards compatibility reaches.
127 * An integer variable exported from the library linked
128 * against at application run time.
132 * glib_interface_age:
134 * The interface age of the GLib library.
135 * Defines how far back the API has last been extended.
137 * An integer variable exported from the library linked
138 * against at application run time.
141 const guint glib_major_version
= GLIB_MAJOR_VERSION
;
142 const guint glib_minor_version
= GLIB_MINOR_VERSION
;
143 const guint glib_micro_version
= GLIB_MICRO_VERSION
;
144 const guint glib_interface_age
= GLIB_INTERFACE_AGE
;
145 const guint glib_binary_age
= GLIB_BINARY_AGE
;
148 * glib_check_version:
149 * @required_major: the required major version
150 * @required_minor: the required minor version
151 * @required_micro: the required micro version
153 * Checks that the GLib library in use is compatible with the
154 * given version. Generally you would pass in the constants
155 * #GLIB_MAJOR_VERSION, #GLIB_MINOR_VERSION, #GLIB_MICRO_VERSION
156 * as the three arguments to this function; that produces
157 * a check that the library in use is compatible with
158 * the version of GLib the application or module was compiled
161 * Compatibility is defined by two things: first the version
162 * of the running library is newer than the version
163 * @required_major.required_minor.@required_micro. Second
164 * the running library must be binary compatible with the
165 * version @required_major.required_minor.@required_micro
166 * (same major version.)
168 * Returns: %NULL if the GLib library is compatible with the
169 * given version, or a string describing the version mismatch.
170 * The returned string is owned by GLib and must not be modified
176 glib_check_version (guint required_major
,
177 guint required_minor
,
178 guint required_micro
)
180 gint glib_effective_micro
= 100 * GLIB_MINOR_VERSION
+ GLIB_MICRO_VERSION
;
181 gint required_effective_micro
= 100 * required_minor
+ required_micro
;
183 if (required_major
> GLIB_MAJOR_VERSION
)
184 return "GLib version too old (major mismatch)";
185 if (required_major
< GLIB_MAJOR_VERSION
)
186 return "GLib version too new (major mismatch)";
187 if (required_effective_micro
< glib_effective_micro
- GLIB_BINARY_AGE
)
188 return "GLib version too new (micro mismatch)";
189 if (required_effective_micro
> glib_effective_micro
)
190 return "GLib version too old (micro mismatch)";