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 <!-- ##### SECTION Stability_Level ##### -->
20 <!-- ##### MACRO G_OS_WIN32 ##### -->
22 This macro is defined only on Windows. So you can bracket
23 Windows-specific code in "#ifdef G_OS_WIN32".
28 <!-- ##### MACRO G_OS_BEOS ##### -->
30 This macro is defined only on BeOS. So you can bracket
31 BeOS-specific code in "#ifdef G_OS_BEOS".
36 <!-- ##### MACRO G_OS_UNIX ##### -->
38 This macro is defined only on UNIX. So you can bracket
39 UNIX-specific code in "#ifdef G_OS_UNIX".
44 <!-- ##### MACRO G_DIR_SEPARATOR ##### -->
46 The directory separator character.
47 This is '/' on UNIX machines and '\' under Windows.
52 <!-- ##### MACRO G_DIR_SEPARATOR_S ##### -->
54 The directory separator as a string.
55 This is "/" on UNIX machines and "\" under Windows.
60 <!-- ##### MACRO G_IS_DIR_SEPARATOR ##### -->
62 Checks whether a character is a directory
63 separator. It returns %TRUE for '/' on UNIX
64 machines and for '\' or '/' under Windows.
71 <!-- ##### MACRO G_SEARCHPATH_SEPARATOR ##### -->
73 The search path separator character.
74 This is ':' on UNIX machines and ';' under Windows.
79 <!-- ##### MACRO G_SEARCHPATH_SEPARATOR_S ##### -->
81 The search path separator as a string.
82 This is ":" on UNIX machines and ";" under Windows.
87 <!-- ##### MACRO TRUE ##### -->
89 Defines the %TRUE value for the #gboolean type.
94 <!-- ##### MACRO FALSE ##### -->
96 Defines the %FALSE value for the #gboolean type.
101 <!-- ##### MACRO NULL ##### -->
103 Defines the standard %NULL pointer.
108 <!-- ##### MACRO MIN ##### -->
110 Calculates the minimum of @a and @b.
115 @Returns: the minimum of @a and @b.
118 <!-- ##### MACRO MAX ##### -->
120 Calculates the maximum of @a and @b.
125 @Returns: the maximum of @a and @b.
128 <!-- ##### MACRO ABS ##### -->
130 Calculates the absolute value of @a.
131 The absolute value is simply the number with any negative sign taken away.
146 @Returns: the absolute value of @a.
149 <!-- ##### MACRO CLAMP ##### -->
151 Ensures that @x is between the limits set by @low and @high. If @low is
152 greater than @high the result is undefined.
158 CLAMP(5, 10, 15) is 10.
161 CLAMP(15, 5, 10) is 10.
164 CLAMP(20, 15, 25) is 20.
169 @x: the value to clamp.
170 @low: the minimum value allowed.
171 @high: the maximum value allowed.
172 @Returns: the value of @x clamped to the range between @low and @high.
175 <!-- ##### MACRO G_STRUCT_MEMBER ##### -->
177 Returns a member of a structure at a given offset, using the given type.
180 @member_type: the type of the struct field.
181 @struct_p: a pointer to a struct.
182 @struct_offset: the offset of the field from the start of the struct, in bytes.
183 @Returns: the struct member.
186 <!-- ##### MACRO G_STRUCT_MEMBER_P ##### -->
188 Returns an untyped pointer to a given offset of a struct.
191 @struct_p: a pointer to a struct.
192 @struct_offset: the offset from the start of the struct, in bytes.
193 @Returns: an untyped pointer to @struct_p plus @struct_offset bytes.
196 <!-- ##### MACRO G_STRUCT_OFFSET ##### -->
198 Returns the offset, in bytes, of a member of a struct.
201 @struct_type: a structure type, e.g. <structname>GtkWidget</structname>.
202 @member: a field in the structure, e.g. <structfield>window</structfield>.
203 @Returns: the offset of @member from the start of @struct_type.
206 <!-- ##### MACRO G_MEM_ALIGN ##### -->
208 Indicates the number of bytes to which memory will be aligned on the
214 <!-- ##### MACRO G_CONST_RETURN ##### -->
216 If %G_DISABLE_CONST_RETURNS is defined, this macro expands to nothing.
217 By default, the macro expands to <literal>const</literal>. The macro
218 should be used in place of <literal>const</literal> for functions that
219 return a value that should not be modified. The purpose of this macro is
220 to allow us to turn on <literal>const</literal> for returned constant
221 strings by default, while allowing programmers who find that annoying to
222 turn it off. This macro should only be used for return values and for
223 <emphasis>out</emphasis> parameters, it doesn't make sense for
224 <emphasis>in</emphasis> parameters.