1 <!-- ##### SECTION Title ##### -->
4 <!-- ##### SECTION Short_Description ##### -->
7 <!-- ##### SECTION Long_Description ##### -->
9 These macros provide a few commonly-used features.
12 <!-- ##### SECTION See_Also ##### -->
17 <!-- ##### MACRO GLIB_MAJOR_VERSION ##### -->
19 The major version number of the GLib library.
24 <!-- ##### MACRO GLIB_MINOR_VERSION ##### -->
26 The minor version number of the GLib library.
31 <!-- ##### MACRO GLIB_MICRO_VERSION ##### -->
33 The micro version number of the GLib library.
38 <!-- ##### MACRO G_OS_WIN32 ##### -->
40 This macro is defined only on Windows. So you can bracket
41 Windows-specific code in "#ifdef G_OS_WIN32".
46 <!-- ##### MACRO G_OS_BEOS ##### -->
48 This macro is defined only on BeOS. So you can bracket
49 BeOS-specific code in "#ifdef G_OS_BEOS".
54 <!-- ##### MACRO G_OS_UNIX ##### -->
56 This macro is defined only on Unix. So you can bracket
57 Unix-specific code in "#ifdef G_OS_UNIX".
62 <!-- ##### MACRO GLIB_CHECK_VERSION ##### -->
64 Checks the version of the GLib library.
65 It returns %TRUE if the GLib library is the same or newer than the given
69 <title>Checking the version of the GLib library.</title>
71 if (!GLIB_CHECK_VERSION (1, 2, 0))
72 g_error ("GLib version 1.2.0 or above is needed");
77 @major: the major version number.
78 @minor: the minor version number.
79 @micro: the micro version number.
82 <!-- ##### MACRO G_DIR_SEPARATOR ##### -->
84 The directory separator character.
85 This is '/' on Unix machines and '\' under Windows.
90 <!-- ##### MACRO G_DIR_SEPARATOR_S ##### -->
92 The directory separator as a string.
93 This is "/" on Unix machines and "\" under Windows.
98 <!-- ##### MACRO G_SEARCHPATH_SEPARATOR ##### -->
100 The search path separator character.
101 This is ':' on Unix machines and ';' under Windows.
106 <!-- ##### MACRO G_SEARCHPATH_SEPARATOR_S ##### -->
108 The search path separator as a string.
109 This is ":" on Unix machines and ";" under Windows.
114 <!-- ##### MACRO TRUE ##### -->
116 Defines the %TRUE value for the #gboolean type.
121 <!-- ##### MACRO FALSE ##### -->
123 Defines the %FALSE value for the #gboolean type.
128 <!-- ##### MACRO NULL ##### -->
130 Defines the standard %NULL pointer.
135 <!-- ##### MACRO MIN ##### -->
137 Calculates the minimum of @a and @b.
142 @Returns: the minimum of @a and @b.
145 <!-- ##### MACRO MAX ##### -->
147 Calculates the maximum of @a and @b.
152 @Returns: the maximum of @a and @b.
155 <!-- ##### MACRO ABS ##### -->
157 Calculates the absolute value of @a.
158 The absolute value is simply the number with any negative sign taken away.
173 @Returns: the absolute value of @a.
176 <!-- ##### MACRO CLAMP ##### -->
178 Ensures that @x is between the limits set by @low and @high.
184 CLAMP(5, 10, 15) is 10.
187 CLAMP(15, 5, 10) is 10.
190 CLAMP(20, 15, 25) is 20.
195 @x: the value to clamp.
196 @low: the minimum value allowed.
197 @high: the maximum value allowed.
198 @Returns: the value of @x clamped to the range between @low and @high.
201 <!-- ##### MACRO G_STRUCT_MEMBER ##### -->
203 Returns a member of a structure at a given offset, using the given type.
206 @member_type: the type of the struct field.
207 @struct_p: a pointer to a struct.
208 @struct_offset: the offset of the field from the start of the struct, in bytes.
209 @Returns: the struct member.
212 <!-- ##### MACRO G_STRUCT_MEMBER_P ##### -->
214 Returns an untyped pointer to a given offset of a struct.
217 @struct_p: a pointer to a struct.
218 @struct_offset: the offset from the start of the struct, in bytes.
219 @Returns: an untyped pointer to @struct_p plus @struct_offset bytes.
222 <!-- ##### MACRO G_STRUCT_OFFSET ##### -->
224 Returns the offset, in bytes, of a member of a struct.
227 @struct_type: a structure type, e.g. <structname>GtkWidget</structname>.
228 @member: a field in the structure, e.g. <structfield>window</structfield>.
229 @Returns: the offset of @member from the start of @struct_type.
232 <!-- ##### MACRO G_MEM_ALIGN ##### -->
234 Indicates the number of bytes to which memory will be aligned on the
240 <!-- ##### MACRO G_CONST_RETURN ##### -->
242 If %G_DISABLE_CONST_RETURNS is defined, this macro expands to nothing.
243 By default, the macro expands to <literal>const</literal>. The macro
244 should be used in place of <literal>const</literal> for functions that
245 return a value that should not be modified. The purpose of this macro is
246 to allow us to turn on <literal>const</literal> for returned constant
247 strings by default, while allowing programmers who find that annoying to
248 turn it off. This macro should only be used for return values and for
249 <emphasis>out</emphasis> parameters, it doesn't make sense for
250 <emphasis>in</emphasis> parameters.