1 <!-- ##### SECTION Title ##### -->
4 <!-- ##### SECTION Short_Description ##### -->
5 specialized macros which are not used often.
7 <!-- ##### SECTION Long_Description ##### -->
9 These macros provide more specialized features which are not needed so often
10 by application programmers.
13 <!-- ##### SECTION See_Also ##### -->
18 <!-- ##### MACRO G_INLINE_FUNC ##### -->
20 Used to declare inline functions. If inline functions are not supported on
21 the particular platform, the macro evaluates to the empty string.
26 <!-- ##### MACRO G_STMT_START ##### -->
28 Used within multi-statement macros so that they can be used in places where
29 only one statement is expected by the compiler.
34 <!-- ##### MACRO G_STMT_END ##### -->
36 Used within multi-statement macros so that they can be used in places where
37 only one statement is expected by the compiler.
42 <!-- ##### MACRO G_BEGIN_DECLS ##### -->
44 Used (along with #G_END_DECLS) to bracket header files. If the
45 compiler in use is a C++ compiler, adds 'extern "C"' around the header.
50 <!-- ##### MACRO G_END_DECLS ##### -->
52 Used (along with #G_BEGIN_DECLS) to bracket header files. If the
53 compiler in use is a C++ compiler, adds <literal>extern "C"</literal>
59 <!-- ##### MACRO G_N_ELEMENTS ##### -->
61 Determines the number of elements in an array. The array must be
62 declared so the compiler knows its size at compile-time; this
63 macro will not work on an array allocated on the heap, only static
64 arrays or arrays on the stack.
70 <!-- ##### MACRO G_VA_COPY ##### -->
72 Portable way to copy <type>va_list</type> variables.
75 In order to use this function, you must include <filename>string.h</filename>
76 yourself, because this macro may use <function>memmove()</function> and GLib
77 does not include <function>string.h</function> for you.
80 @ap1: the <type>va_list</type> variable to place a copy of @ap2 in.
81 @ap2: a <type>va_list</type>.
84 <!-- ##### MACRO G_STRINGIFY ##### -->
86 Accepts a macro or a string and converts it into a string.
89 @macro_or_string: a macro or a string.
92 <!-- ##### MACRO G_GNUC_EXTENSION ##### -->
94 Expands to <literal>__extension__</literal> when GNU C is used as the compiler.
95 This simply tells GNU C not to warn about the following non-standard code
96 when compiling with the <literal>-pedantic</literal> option.
101 <!-- ##### MACRO G_GNUC_NORETURN ##### -->
103 Expands to the GNU C noreturn function attribute if the compiler is GNU C.
104 It is used for declaring functions which never return.
105 It enables optimization of the function, and avoids possible compiler
106 warnings. See the GNU C documentation for details.
111 <!-- ##### MACRO G_GNUC_UNUSED ##### -->
113 Expands to the GNU C unused function attribute if the compiler is GNU C.
114 It is used for declaring functions which may never be used.
115 It avoids possible compiler warnings. See the GNU C documentation for details.
120 <!-- ##### MACRO G_GNUC_PURE ##### -->
122 Expands to the GNU C pure function attribute if the compiler is GNU C.
123 Declaring a function as pure enables better optimization of the function.
124 A pure function has no effects except its return value and the return
125 value depends only on the parameters and/or global variables.
126 See the GNU C documentation for details.
130 <!-- ##### MACRO G_GNUC_CONST ##### -->
132 Expands to the GNU C const function attribute if the compiler is GNU C.
133 Declaring a function as const enables better optimization of the function.
134 A const function doesn't examine any values except its parameters,
135 and has no effects except its return value.
136 See the GNU C documentation for details.
139 A function that has pointer arguments and examines the data pointed to
140 must <emphasis>not</emphasis> be declared const. Likewise, a function that
141 calls a non-const function usually must not be const. It doesn't make sense
142 for a const function to return void.
146 <!-- ##### MACRO G_GNUC_PRINTF ##### -->
148 Expands to the GNU C format function attribute if the compiler is GNU C.
149 This is used for declaring functions which take a variable number of
150 arguments, with the same syntax as <function>printf()</function>.
151 It allows the compiler to type-check the arguments passed to the function.
152 See the GNU C documentation for details.
154 <informalexample><programlisting>
155 gint g_snprintf (gchar *string,
158 ...) G_GNUC_PRINTF (3, 4);
159 </programlisting></informalexample>
161 @format_idx: the index of the argument corresponding to the format string.
162 (The arguments are numbered from 1).
163 @arg_idx: the index of the first of the format arguments.
166 <!-- ##### MACRO G_GNUC_SCANF ##### -->
168 Expands to the GNU C format function attribute if the compiler is GNU C.
169 This is used for declaring functions which take a variable number of
170 arguments, with the same syntax as <function>scanf()</function>.
171 It allows the compiler to type-check the arguments passed to the function.
172 See the GNU C documentation for details.
175 @format_idx: the index of the argument corresponding to the format string.
176 (The arguments are numbered from 1).
177 @arg_idx: the index of the first of the format arguments.
180 <!-- ##### MACRO G_GNUC_FORMAT ##### -->
182 Expands to the GNU C format_arg function attribute if the compiler is GNU C.
183 The format_arg function attribute specifies that a function takes a format
184 string for a <function>printf()</function>, <function>scanf()</function>,
185 <function>strftime()</function> or <function>strfmon()</function> style
186 function and modifies it, so that the result can be passed to a
187 <function>printf()</function>, <function>scanf()</function>,
188 <function>strftime()</function> or <function>strfmon()</function> style
189 function (with the remaining arguments to the format function the same as
190 they would have been for the unmodified string).
191 See the GNU C documentation for details.
193 <informalexample><programlisting>
194 gchar *g_dgettext (gchar *domain_name, gchar *msgid) G_GNUC_FORMAT (2);
195 </programlisting></informalexample>
197 @arg_idx: the index of the argument.
200 <!-- ##### MACRO G_GNUC_FUNCTION ##### -->
202 Expands to the GNU C <literal>__FUNCTION__</literal> variable if the
203 compiler is GNU C, or "" if it isn't. The GNU C
204 <literal>__FUNCTION__</literal> variable contains the name of the
205 current function. See the GNU C documentation for details.
210 <!-- ##### MACRO G_GNUC_PRETTY_FUNCTION ##### -->
212 Expands to the GNU C <literal>__PRETTY_FUNCTION__</literal> variable
213 if the compiler is GNU C, or "" if it isn't.
214 The GNU C <literal>__PRETTY_FUNCTION__</literal> variable contains the
215 name of the current function. For a C program this is the same as the
216 <literal>__FUNCTION__</literal> variable but for C++ it also includes
217 extra information such as the class and function prototype. See the
218 GNU C documentation for details.
223 <!-- ##### MACRO G_GNUC_NO_INSTRUMENT ##### -->
225 Expands to the GNU C no_instrument_function function attribute if
226 the compiler is GNU C. Functions with this attribute will not be
227 instrumented for profiling, when the compiler is called with the
228 <option>-finstrument-functions</option> option.
229 See the GNU C documentation for details.
234 <!-- ##### MACRO G_STRLOC ##### -->
236 Expands to a string identifying the current code position.
241 <!-- ##### MACRO G_GINT16_FORMAT ##### -->
243 This is the platform dependent conversion specifier for scanning and
244 printing values of type #gint16. It is a string literal, but doesn't
245 include the percent-sign, such that you can add precision and length
246 modifiers between percent-sign and conversion specifier.
254 sscanf ("42", "%" G_GINT16_FORMAT, &in)
256 g_print ("%" G_GINT32_FORMAT, out);
263 <!-- ##### MACRO G_GUINT16_FORMAT ##### -->
265 This is the platform dependent conversion specifier for scanning and
266 printing values of type #guint16. See also #G_GINT16_FORMAT.
271 <!-- ##### MACRO G_GINT32_FORMAT ##### -->
273 This is the platform dependent conversion specifier for scanning and
274 printing values of type #gint32. See also #G_GINT16_FORMAT.
279 <!-- ##### MACRO G_GUINT32_FORMAT ##### -->
281 This is the platform dependent conversion specifier for scanning and
282 printing values of type #guint32. See also #G_GINT16_FORMAT.
287 <!-- ##### MACRO G_GINT64_FORMAT ##### -->
289 This is the platform dependent conversion specifier for scanning and
290 printing values of type #gint64. See also #G_GINT16_FORMAT.
295 Some platforms do not support scanning and printing 64 bit integers,
296 even though the types are supported. On such platforms #G_GINT64_FORMAT
303 <!-- ##### MACRO G_GUINT64_FORMAT ##### -->
305 This is the platform dependent conversion specifier for scanning and
306 printing values of type #guint64. See also #G_GINT16_FORMAT.
311 Some platforms do not support scanning and printing 64 bit integers,
312 even though the types are supported. On such platforms #G_GUINT64_FORMAT