|
Packit |
db3073 |
/* GLIB - Library of useful routines for C programming
|
|
Packit |
db3073 |
* Copyright (C) 1995-1998 Peter Mattis, Spencer Kimball and Josh MacDonald
|
|
Packit |
db3073 |
*
|
|
Packit |
db3073 |
* This library is free software; you can redistribute it and/or
|
|
Packit |
db3073 |
* modify it under the terms of the GNU Lesser General Public
|
|
Packit |
db3073 |
* License as published by the Free Software Foundation; either
|
|
Packit |
db3073 |
* version 2 of the License, or (at your option) any later version.
|
|
Packit |
db3073 |
*
|
|
Packit |
db3073 |
* This library is distributed in the hope that it will be useful,
|
|
Packit |
db3073 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
db3073 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
db3073 |
* Lesser General Public License for more details.
|
|
Packit |
db3073 |
*
|
|
Packit |
db3073 |
* You should have received a copy of the GNU Lesser General Public
|
|
Packit |
db3073 |
* License along with this library; if not, write to the
|
|
Packit |
db3073 |
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
Packit |
db3073 |
* Boston, MA 02111-1307, USA.
|
|
Packit |
db3073 |
*/
|
|
Packit |
db3073 |
|
|
Packit |
db3073 |
/*
|
|
Packit |
db3073 |
* Modified by the GLib Team and others 1997-2000. See the AUTHORS
|
|
Packit |
db3073 |
* file for a list of people on the GLib Team. See the ChangeLog
|
|
Packit |
db3073 |
* files for a list of changes. These files are distributed with
|
|
Packit |
db3073 |
* GLib at ftp://ftp.gtk.org/pub/gtk/.
|
|
Packit |
db3073 |
*/
|
|
Packit |
db3073 |
|
|
Packit |
db3073 |
#include "config.h"
|
|
Packit |
db3073 |
|
|
Packit |
db3073 |
#include "gversion.h"
|
|
Packit |
db3073 |
|
|
Packit |
db3073 |
/**
|
|
Packit |
db3073 |
* SECTION:version
|
|
Packit |
db3073 |
* @Title: Version Information
|
|
Packit |
db3073 |
* @Short_description: variables and functions to check the GLib version
|
|
Packit |
db3073 |
*
|
|
Packit |
db3073 |
* GLib provides version information, primarily useful in configure
|
|
Packit |
db3073 |
* checks for builds that have a configure script. Applications will
|
|
Packit |
db3073 |
* not typically use the features described here.
|
|
Packit |
db3073 |
*
|
|
Packit |
db3073 |
* The GLib headers annotate deprecated APIs in a way that produces
|
|
Packit |
db3073 |
* compiler warnings if these deprecated APIs are used. The warnings
|
|
Packit |
db3073 |
* can be turned off by defining the macro %GLIB_DISABLE_DEPRECATION_WARNINGS
|
|
Packit |
db3073 |
* before including the glib.h header.
|
|
Packit |
db3073 |
*
|
|
Packit |
db3073 |
* GLib also provides support for building applications against
|
|
Packit |
db3073 |
* defined subsets of deprecated or new GLib APIs. Define the macro
|
|
Packit |
db3073 |
* %GLIB_VERSION_MIN_REQUIRED to specify up to what version of GLib
|
|
Packit |
db3073 |
* you want to receive warnings about deprecated APIs. Define the
|
|
Packit |
db3073 |
* macro %GLIB_VERSION_MAX_ALLOWED to specify the newest version of
|
|
Packit |
db3073 |
* GLib whose API you want to use.
|
|
Packit |
db3073 |
*/
|
|
Packit |
db3073 |
|
|
Packit |
db3073 |
/**
|
|
Packit |
db3073 |
* GLIB_MAJOR_VERSION:
|
|
Packit |
db3073 |
*
|
|
Packit |
db3073 |
* The major version number of the GLib library.
|
|
Packit |
db3073 |
*
|
|
Packit |
db3073 |
* Like #glib_major_version, but from the headers used at
|
|
Packit |
db3073 |
* application compile time, rather than from the library
|
|
Packit |
db3073 |
* linked against at application run time.
|
|
Packit |
db3073 |
*/
|
|
Packit |
db3073 |
|
|
Packit |
db3073 |
/**
|
|
Packit |
db3073 |
* GLIB_MINOR_VERSION:
|
|
Packit |
db3073 |
*
|
|
Packit |
db3073 |
* The minor version number of the GLib library.
|
|
Packit |
db3073 |
*
|
|
Packit |
db3073 |
* Like #gtk_minor_version, but from the headers used at
|
|
Packit |
db3073 |
* application compile time, rather than from the library
|
|
Packit |
db3073 |
* linked against at application run time.
|
|
Packit |
db3073 |
*/
|
|
Packit |
db3073 |
|
|
Packit |
db3073 |
/**
|
|
Packit |
db3073 |
* GLIB_MICRO_VERSION:
|
|
Packit |
db3073 |
*
|
|
Packit |
db3073 |
* The micro version number of the GLib library.
|
|
Packit |
db3073 |
*
|
|
Packit |
db3073 |
* Like #gtk_micro_version, but from the headers used at
|
|
Packit |
db3073 |
* application compile time, rather than from the library
|
|
Packit |
db3073 |
* linked against at application run time.
|
|
Packit |
db3073 |
*/
|
|
Packit |
db3073 |
|
|
Packit |
db3073 |
/**
|
|
Packit |
db3073 |
* GLIB_CHECK_VERSION:
|
|
Packit |
db3073 |
* @major: the major version to check for
|
|
Packit |
db3073 |
* @minor: the minor version to check for
|
|
Packit |
db3073 |
* @micro: the micro version to check for
|
|
Packit |
db3073 |
*
|
|
Packit |
db3073 |
* Checks the version of the GLib library that is being compiled
|
|
Packit |
db3073 |
* against.
|
|
Packit |
db3073 |
*
|
|
Packit |
db3073 |
* <example>
|
|
Packit |
db3073 |
* <title>Checking the version of the GLib library</title>
|
|
Packit |
db3073 |
* <programlisting>
|
|
Packit |
db3073 |
* if (!GLIB_CHECK_VERSION (1, 2, 0))
|
|
Packit |
db3073 |
* g_error ("GLib version 1.2.0 or above is needed");
|
|
Packit |
db3073 |
* </programlisting>
|
|
Packit |
db3073 |
* </example>
|
|
Packit |
db3073 |
*
|
|
Packit |
db3073 |
* See glib_check_version() for a runtime check.
|
|
Packit |
db3073 |
*
|
|
Packit |
db3073 |
* Returns: %TRUE if the version of the GLib header files
|
|
Packit |
db3073 |
* is the same as or newer than the passed-in version.
|
|
Packit |
db3073 |
*/
|
|
Packit |
db3073 |
|
|
Packit |
db3073 |
const guint glib_major_version = GLIB_MAJOR_VERSION;
|
|
Packit |
db3073 |
const guint glib_minor_version = GLIB_MINOR_VERSION;
|
|
Packit |
db3073 |
const guint glib_micro_version = GLIB_MICRO_VERSION;
|
|
Packit |
db3073 |
const guint glib_interface_age = GLIB_INTERFACE_AGE;
|
|
Packit |
db3073 |
const guint glib_binary_age = GLIB_BINARY_AGE;
|
|
Packit |
db3073 |
|
|
Packit |
db3073 |
/**
|
|
Packit |
db3073 |
* glib_check_version:
|
|
Packit |
db3073 |
* @required_major: the required major version.
|
|
Packit |
db3073 |
* @required_minor: the required minor version.
|
|
Packit |
db3073 |
* @required_micro: the required micro version.
|
|
Packit |
db3073 |
*
|
|
Packit |
db3073 |
* Checks that the GLib library in use is compatible with the
|
|
Packit |
db3073 |
* given version. Generally you would pass in the constants
|
|
Packit |
db3073 |
* #GLIB_MAJOR_VERSION, #GLIB_MINOR_VERSION, #GLIB_MICRO_VERSION
|
|
Packit |
db3073 |
* as the three arguments to this function; that produces
|
|
Packit |
db3073 |
* a check that the library in use is compatible with
|
|
Packit |
db3073 |
* the version of GLib the application or module was compiled
|
|
Packit |
db3073 |
* against.
|
|
Packit |
db3073 |
*
|
|
Packit |
db3073 |
* Compatibility is defined by two things: first the version
|
|
Packit |
db3073 |
* of the running library is newer than the version
|
|
Packit |
db3073 |
* @required_major.required_minor.@required_micro. Second
|
|
Packit |
db3073 |
* the running library must be binary compatible with the
|
|
Packit |
db3073 |
* version @required_major.required_minor.@required_micro
|
|
Packit |
db3073 |
* (same major version.)
|
|
Packit |
db3073 |
*
|
|
Packit |
db3073 |
* Return value: %NULL if the GLib library is compatible with the
|
|
Packit |
db3073 |
* given version, or a string describing the version mismatch.
|
|
Packit |
db3073 |
* The returned string is owned by GLib and must not be modified
|
|
Packit |
db3073 |
* or freed.
|
|
Packit |
db3073 |
*
|
|
Packit |
db3073 |
* Since: 2.6
|
|
Packit |
db3073 |
*/
|
|
Packit |
db3073 |
const gchar *
|
|
Packit |
db3073 |
glib_check_version (guint required_major,
|
|
Packit |
db3073 |
guint required_minor,
|
|
Packit |
db3073 |
guint required_micro)
|
|
Packit |
db3073 |
{
|
|
Packit |
db3073 |
gint glib_effective_micro = 100 * GLIB_MINOR_VERSION + GLIB_MICRO_VERSION;
|
|
Packit |
db3073 |
gint required_effective_micro = 100 * required_minor + required_micro;
|
|
Packit |
db3073 |
|
|
Packit |
db3073 |
if (required_major > GLIB_MAJOR_VERSION)
|
|
Packit |
db3073 |
return "GLib version too old (major mismatch)";
|
|
Packit |
db3073 |
if (required_major < GLIB_MAJOR_VERSION)
|
|
Packit |
db3073 |
return "GLib version too new (major mismatch)";
|
|
Packit |
db3073 |
if (required_effective_micro < glib_effective_micro - GLIB_BINARY_AGE)
|
|
Packit |
db3073 |
return "GLib version too new (micro mismatch)";
|
|
Packit |
db3073 |
if (required_effective_micro > glib_effective_micro)
|
|
Packit |
db3073 |
return "GLib version too old (micro mismatch)";
|
|
Packit |
db3073 |
return NULL;
|
|
Packit |
db3073 |
}
|