1Glib::version(3)      User Contributed Perl Documentation     Glib::version(3)
2
3
4

NAME

6       Glib::version -  Library Versioning Utilities
7

SYNOPSIS

9         # require at least version 1.021 of the Glib module
10         use Glib '1.021';
11
12         # g_set_application_name() was introduced in GLib 2.2.0, and
13         # first supported by version 1.040 of the Glib Perl module.
14         if ($Glib::VERSION >= 1.040 and Glib->CHECK_VERSION (2,2,0)) {
15            Glib::set_application_name ('My Cool Program');
16         }
17

DESCRIPTION

19       Both the Glib module and the GLib C library are works-in-progress, and
20       their interfaces grow over time.  As more features are added to each,
21       and your code uses those new features, you will introduce version-spe‐
22       cific dependencies, and naturally, you'll want to be able to code
23       around them.  Enter the versioning API.
24
25       For simple Perl modules, a single version number is sufficient; how‐
26       ever, Glib is a binding to another software library, and this intro‐
27       duces some complexity.  We have three versions that fully specify the
28       API available to you.
29
30       Perl Bindings Version
31           Perl modules use a version number, and Glib is no exception.
32           $Glib::VERSION is the version of the current Glib module.  By ad
33           hoc convention, gtk2-perl modules generally use version numbers in
34           the form x.yyz, where even yy values denote stable releases and z
35           is a patchlevel.
36
37              $Glib::VERSION
38              use Glib 1.040; # require at least version 1.040
39
40       Compile-time ("Bound") Library Version
41           This is the version of the GLib C library that was available when
42           the Perl module was compiled and installed.  These version con‐
43           stants are equivalent to the version macros provided in the GLib C
44           headers.  GLib uses a major.minor.micro convention, where even
45           minor versions are stable.  (gtk2-perl does not officially support
46           unstable versions.)
47
48              Glib::MAJOR_VERSION
49              Glib::MINOR_VERSION
50              Glib::MICRO_VERSION
51              Glib->CHECK_VERSION($maj,$min,$mic)
52
53       Run-time ("Linked") Library Version
54           This is the version of the GLib C library that is available at run
55           time; it may be newer than the compile-time version, but should
56           never be older.  These are equivalent to the version variables
57           exported by the GLib C library.
58
59              Glib::major_version
60              Glib::minor_version
61              Glib::micro_version
62
63       Which one do I use when?
64
65       Where do you use which version?  It depends entirely on what you're
66       doing.  Let's explain by example:
67
68       o Use the Perl module version for bindings support issues
69           You need to register a new enum for use as the type of an object
70           property.  This is something you can do with all versions of the
71           underlying C library, but which wasn't supported in the Glib Perl
72           module until $Glib::VERSION >= 1.040.
73
74       o Use the bound version for library features
75           You want to call Glib::set_application_name to set a human-readable
76           name for your application (which is used by various parts of Gtk2
77           and Gnome2).  g_set_application_name() (the underlying C function)
78           was added in version 2.2.0 of glib, and support for it was intro‐
79           duced into the Glib Perl module in Glib version 1.040.  However,
80           you can build the Perl module against any stable 2.x.x version of
81           glib, so you might not have that function available even if your
82           Glib module is new enough!
83             Thus, you need to check two things to see if the this function is
84           available:
85
86              if ($Glib::VERSION >= 1.040 && Glib->CHECK_VERSION (2,2,0)) {
87                  # it's available, and we can call it!
88                  Glib::set_application_name ('My Cool Application');
89              }
90
91           Now what happens if you installed the Perl module when your system
92           had glib 2.0.6, and you upgraded glib to 2.4.1?  Wouldn't
93           g_set_application_name() be available?  Well, it's there, under the
94           hood, but the bindings were compiled when it wasn't there, so you
95           won't be able to call it!  That's why we check the "bound" or com‐
96           pile-time version.  By the way, to enable support for the new func‐
97           tion, you'd need to reinstall (or upgrade) the Perl module.
98
99       o Use the linked version for runtime work-arounds
100           Suppose there's a function whose API did not change, but whose
101           implementation had a bug in one version that was fixed in another
102           version.  To determine whether you need to apply a workaround, you
103           would check the version that is actually being used at runtime.
104
105              if (Glib::major_version == 2 &&
106                  Glib::minor_version == 2 &&
107                  Glib::micro_version == 1) {
108                 # work around bug that exists only in glib 2.2.1.
109              }
110
111           In practice, such situations are very rare.
112

METHODS

114       boolean = Glib->CHECK_VERSION ($required_major, $required_minor,
115       $required_micro)
116
117           * $required_major (integer)
118           * $required_minor (integer)
119           * $required_micro (integer)
120
121           Provides a mechanism for checking the version information that Glib
122           was compiled against. Essentially equvilent to the macro
123           GLIB_CHECK_VERSION.
124
125       (MAJOR, MINOR, MICRO) = Glib->GET_VERSION_INFO
126
127           Shorthand to fetch as a list the glib version for which Glib was
128           compiled.  See "Glib::MAJOR_VERSION", etc.
129
130       integer = Glib::MAJOR_VERSION
131
132           Provides access to the version information that Glib was compiled
133           against.  Essentially equivalent to the #define's GLIB_MAJOR_VER‐
134           SION.
135
136       integer = Glib::MICRO_VERSION
137
138           Provides access to the version information that Glib was compiled
139           against.  Essentially equivalent to the #define's GLIB_MICRO_VER‐
140           SION.
141
142       integer = Glib::MINOR_VERSION
143
144           Provides access to the version information that Glib was compiled
145           against.  Essentially equivalent to the #define's GLIB_MINOR_VER‐
146           SION.
147
148       integer = Glib::major_version
149
150           Provides access to the version information that Glib is linked
151           against.  Essentially equivalent to the global variable
152           glib_major_version.
153
154       integer = Glib::micro_version
155
156           Provides access to the version information that Glib is linked
157           against.  Essentially equivalent to the global variable
158           glib_micro_version.
159
160       integer = Glib::minor_version
161
162           Provides access to the version information that Glib is linked
163           against.  Essentially equivalent to the global variable
164           glib_minor_version.
165

SEE ALSO

167       Glib
168
170       Copyright (C) 2003-2007 by the gtk2-perl team.
171
172       This software is licensed under the LGPL.  See Glib for a full notice.
173
174
175
176perl v5.8.8                       2007-02-26                  Glib::version(3)
Impressum