.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Glib::version 3pm" .TH Glib::version 3pm "2022-10-19" "perl v5.36.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Glib::version \- Library Versioning Utilities .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& # require at least version 1.021 of the Glib module \& use Glib \*(Aq1.021\*(Aq; \& \& # g_set_application_name() was introduced in GLib 2.2.0, and \& # first supported by version 1.040 of the Glib Perl module. \& if ($Glib::VERSION >= 1.040 and Glib\->CHECK_VERSION (2,2,0)) { \& Glib::set_application_name (\*(AqMy Cool Program\*(Aq); \& } .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Both the Glib module and the GLib C library are works-in-progress, and their interfaces grow over time. As more features are added to each, and your code uses those new features, you will introduce version-specific dependencies, and naturally, you'll want to be able to code around them. Enter the versioning \s-1API.\s0 .PP For simple Perl modules, a single version number is sufficient; however, Glib is a binding to another software library, and this introduces some complexity. We have three versions that fully specify the \s-1API\s0 available to you. .IP "Perl Bindings Version" 4 .IX Item "Perl Bindings Version" Perl modules use a version number, and Glib is no exception. \&\fI\f(CI$Glib::VERSION\fI\fR is the version of the current Glib module. By ad hoc convention, gtk2\-perl modules generally use version numbers in the form x.yyz, where even yy values denote stable releases and z is a patchlevel. .Sp .Vb 2 \& $Glib::VERSION \& use Glib 1.040; # require at least version 1.040 .Ve .ie n .IP "Compile-time (""Bound"") Library Version" 4 .el .IP "Compile-time (``Bound'') Library Version" 4 .IX Item "Compile-time (Bound) Library Version" This is the version of the GLib C library that was available when the Perl module was compiled and installed. These version constants are equivalent to the version macros provided in the GLib C headers. GLib uses a major.minor.micro convention, where even minor versions are stable. (gtk2\-perl does not officially support unstable versions.) .Sp .Vb 4 \& Glib::MAJOR_VERSION \& Glib::MINOR_VERSION \& Glib::MICRO_VERSION \& Glib\->CHECK_VERSION($maj,$min,$mic) .Ve .ie n .IP "Run-time (""Linked"") Library Version" 4 .el .IP "Run-time (``Linked'') Library Version" 4 .IX Item "Run-time (Linked) Library Version" This is the version of the GLib C library that is available at run time; it may be newer than the compile-time version, but should never be older. These are equivalent to the version variables exported by the GLib C library. .Sp .Vb 3 \& Glib::major_version \& Glib::minor_version \& Glib::micro_version .Ve .SS "Which one do I use when?" .IX Subsection "Which one do I use when?" Where do you use which version? It depends entirely on what you're doing. Let's explain by example: .IP "o Use the Perl module version for bindings support issues" 4 .IX Item "o Use the Perl module version for bindings support issues" You need to register a new enum for use as the type of an object property. This is something you can do with all versions of the underlying C library, but which wasn't supported in the Glib Perl module until \f(CW$Glib::VERSION\fR >= 1.040. .IP "o Use the bound version for library features" 4 .IX Item "o Use the bound version for library features" You want to call Glib::set_application_name to set a human-readable name for your application (which is used by various parts of Gtk2 and Gnome2). \&\fBg_set_application_name()\fR (the underlying C function) was added in version 2.2.0 of glib, and support for it was introduced into the Glib Perl module in Glib version 1.040. However, you can build the Perl module against any stable 2.x.x version of glib, so you might not have that function available even if your Glib module is new enough! Thus, you need to check two things to see if the this function is available: .Sp .Vb 4 \& if ($Glib::VERSION >= 1.040 && Glib\->CHECK_VERSION (2,2,0)) { \& # it\*(Aqs available, and we can call it! \& Glib::set_application_name (\*(AqMy Cool Application\*(Aq); \& } .Ve .Sp Now what happens if you installed the Perl module when your system had glib 2.0.6, and you upgraded glib to 2.4.1? Wouldn't \fBg_set_application_name()\fR be available? Well, it's there, under the hood, but the bindings were compiled when it wasn't there, so you won't be able to call it! That's why we check the \*(L"bound\*(R" or compile-time version. By the way, to enable support for the new function, you'd need to reinstall (or upgrade) the Perl module. .IP "o Use the linked version for runtime work-arounds" 4 .IX Item "o Use the linked version for runtime work-arounds" Suppose there's a function whose \s-1API\s0 did not change, but whose implementation had a bug in one version that was fixed in another version. To determine whether you need to apply a workaround, you would check the version that is actually being used at runtime. .Sp .Vb 5 \& if (Glib::major_version == 2 && \& Glib::minor_version == 2 && \& Glib::micro_version == 1) { \& # work around bug that exists only in glib 2.2.1. \& } .Ve .Sp In practice, such situations are very rare. .SH "METHODS" .IX Header "METHODS" .ie n .SS "boolean = Glib\->\fB\s-1CHECK_VERSION\s0\fP ($required_major, $required_minor, $required_micro)" .el .SS "boolean = Glib\->\fB\s-1CHECK_VERSION\s0\fP ($required_major, \f(CW$required_minor\fP, \f(CW$required_micro\fP)" .IX Subsection "boolean = Glib->CHECK_VERSION ($required_major, $required_minor, $required_micro)" .IP "\(bu" 4 \&\f(CW$required_major\fR (integer) .IP "\(bu" 4 \&\f(CW$required_minor\fR (integer) .IP "\(bu" 4 \&\f(CW$required_micro\fR (integer) .PP Provides a mechanism for checking the version information that Glib was compiled against. Essentially equvilent to the macro \s-1GLIB_CHECK_VERSION.\s0 .SS "(\s-1MAJOR, MINOR, MICRO\s0) = Glib\->\fB\s-1GET_VERSION_INFO\s0\fP" .IX Subsection "(MAJOR, MINOR, MICRO) = Glib->GET_VERSION_INFO" Shorthand to fetch as a list the glib version for which Glib was compiled. See \f(CW\*(C`Glib::MAJOR_VERSION\*(C'\fR, etc. .SS "integer = Glib::MAJOR_VERSION" .IX Subsection "integer = Glib::MAJOR_VERSION" Provides access to the version information that Glib was compiled against. Essentially equivalent to the #define's \s-1GLIB_MAJOR_VERSION.\s0 .SS "integer = Glib::MICRO_VERSION" .IX Subsection "integer = Glib::MICRO_VERSION" Provides access to the version information that Glib was compiled against. Essentially equivalent to the #define's \s-1GLIB_MICRO_VERSION.\s0 .SS "integer = Glib::MINOR_VERSION" .IX Subsection "integer = Glib::MINOR_VERSION" Provides access to the version information that Glib was compiled against. Essentially equivalent to the #define's \s-1GLIB_MINOR_VERSION.\s0 .SS "integer = Glib::major_version" .IX Subsection "integer = Glib::major_version" Provides access to the version information that Glib is linked against. Essentially equivalent to the global variable glib_major_version. .SS "integer = Glib::micro_version" .IX Subsection "integer = Glib::micro_version" Provides access to the version information that Glib is linked against. Essentially equivalent to the global variable glib_micro_version. .SS "integer = Glib::minor_version" .IX Subsection "integer = Glib::minor_version" Provides access to the version information that Glib is linked against. Essentially equivalent to the global variable glib_minor_version. .SH "SEE ALSO" .IX Header "SEE ALSO" Glib .SH "COPYRIGHT" .IX Header "COPYRIGHT" Copyright (C) 2003\-2011 by the gtk2\-perl team. .PP This software is licensed under the \s-1LGPL.\s0 See Glib for a full notice.