GLib版本信息

GLib版本信息 — 检查GLib版本信息的变量和函数

Synopsis

#include <glib.h>

extern              const guint glib_major_version;
extern              const guint glib_minor_version;
extern              const guint glib_micro_version;
extern              const guint glib_binary_age;
extern              const guint glib_interface_age;
const gchar *       glib_check_version                  (guint required_major,
                                                         guint required_minor,
                                                         guint required_micro);

#define             GLIB_MAJOR_VERSION
#define             GLIB_MINOR_VERSION
#define             GLIB_MICRO_VERSION
#define             GLIB_CHECK_VERSION                  (major,
                                                         minor,
                                                         micro)

Description

GLib提供了版本信息,主要在编译脚本中用来做配置检查。通常应用程序不会使用到这些信息。

Details

glib_major_version

extern const guint glib_major_version;


glib_minor_version

extern const guint glib_minor_version;


glib_micro_version

extern const guint glib_micro_version;


glib_binary_age

extern const guint glib_binary_age;


glib_interface_age

extern const guint glib_interface_age;


glib_check_version ()

const gchar *       glib_check_version                  (guint required_major,
                                                         guint required_minor,
                                                         guint required_micro);

检查当前使用的GLib库的版本和指定的版本是否兼容。通常把GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION, GLIB_MICRO_VERSION这三个宏作为传入参数,用来检查当前编 译的应用程序或者模块和链接的GLib库是否兼容。

Compatibility is defined by two things: first the version of the running library is newer than the version required_major.required_minor.required_micro. Second the running library must be binary compatible with the version required_major.required_minor.required_micro (same major version.)

required_major :

要求的主版本号

required_minor :

要求的次版本号

required_micro :

要求的小版本号

Returns :

如果版本可以兼容,返回NULL。如果版本不兼容,返回一个版本不匹配 的字符串。返回的是GLib的字符串,应用程序不要去修改或者释放。

Since 2.6


GLIB_MAJOR_VERSION

#define GLIB_MAJOR_VERSION 2

GLib头文件的主版本号。来自于应用程序编译时使用的头文件的主版本号,而不是来自链接的库文件的主版本号。


GLIB_MINOR_VERSION

#define GLIB_MINOR_VERSION 26

GLib头文件的次版本号。来自于应用程序编译时使用的头文件的次版本号,而不是来自链接的库文件的次版本号。


GLIB_MICRO_VERSION

#define GLIB_MICRO_VERSION 1

GLib头文件的小版本号。来自于应用程序编译时使用的头文件的小版本号,而不是来自链接的库文件的小版本号。


GLIB_CHECK_VERSION()

#define             GLIB_CHECK_VERSION(major,minor,micro)

检查GLib的版本。 如果引用的GLib头文件的版本与传入的版本号相同,或者比传入的版本号更新,则返回TRUE

Example 1. 检查GLib的版本号

  if (!GLIB_CHECK_VERSION (1, 2, 0))
    g_error ("GLib version 1.2.0 or above is needed");


major :

主版本号。

minor :

次版本号。

micro :

小版本号。