1
<refentry id="glib-Miscellaneous-Macros">
3
<refentrytitle role="top_of_page">Miscellaneous Macros</refentrytitle>
4
<manvolnum>3</manvolnum>
5
<refmiscinfo>GLIB Library</refmiscinfo>
9
<refname>Miscellaneous Macros</refname>
10
<refpurpose>specialized macros which are not used often.</refpurpose>
11
<!--[<xref linkend="desc" endterm="desc.title"/>]-->
14
<refsynopsisdiv role="synopsis">
15
<title role="synopsis.title">Synopsis</title>
19
#include <glib.h>
22
#define <link linkend="G-INLINE-FUNC:CAPS">G_INLINE_FUNC</link>
24
#define <link linkend="G-STMT-START:CAPS">G_STMT_START</link>
25
#define <link linkend="G-STMT-END:CAPS">G_STMT_END</link>
27
#define <link linkend="G-BEGIN-DECLS:CAPS">G_BEGIN_DECLS</link>
28
#define <link linkend="G-END-DECLS:CAPS">G_END_DECLS</link>
30
#define <link linkend="G-N-ELEMENTS:CAPS">G_N_ELEMENTS</link> (arr)
32
#define <link linkend="G-VA-COPY:CAPS">G_VA_COPY</link> (ap1,ap2)
34
#define <link linkend="G-STRINGIFY:CAPS">G_STRINGIFY</link> (macro_or_string)
36
#define <link linkend="G-GNUC-EXTENSION:CAPS">G_GNUC_EXTENSION</link>
37
#define <link linkend="G-GNUC-CONST:CAPS">G_GNUC_CONST</link>
38
#define <link linkend="G-GNUC-PURE:CAPS">G_GNUC_PURE</link>
39
#define <link linkend="G-GNUC-MALLOC:CAPS">G_GNUC_MALLOC</link>
40
#define <link linkend="G-GNUC-DEPRECATED:CAPS">G_GNUC_DEPRECATED</link>
41
#define <link linkend="G-GNUC-NORETURN:CAPS">G_GNUC_NORETURN</link>
42
#define <link linkend="G-GNUC-UNUSED:CAPS">G_GNUC_UNUSED</link>
43
#define <link linkend="G-GNUC-PRINTF:CAPS">G_GNUC_PRINTF</link> ( format_idx, arg_idx )
44
#define <link linkend="G-GNUC-SCANF:CAPS">G_GNUC_SCANF</link> ( format_idx, arg_idx )
45
#define <link linkend="G-GNUC-FORMAT:CAPS">G_GNUC_FORMAT</link> ( arg_idx )
46
#define <link linkend="G-GNUC-NULL-TERMINATED:CAPS">G_GNUC_NULL_TERMINATED</link>
47
#define <link linkend="G-GNUC-WARN-UNUSED-RESULT:CAPS">G_GNUC_WARN_UNUSED_RESULT</link>
48
#define <link linkend="G-GNUC-FUNCTION:CAPS">G_GNUC_FUNCTION</link>
49
#define <link linkend="G-GNUC-PRETTY-FUNCTION:CAPS">G_GNUC_PRETTY_FUNCTION</link>
50
#define <link linkend="G-GNUC-NO-INSTRUMENT:CAPS">G_GNUC_NO_INSTRUMENT</link>
51
#define <link linkend="G-HAVE-GNUC-VISIBILITY:CAPS">G_HAVE_GNUC_VISIBILITY</link>
52
#define <link linkend="G-GNUC-INTERNAL:CAPS">G_GNUC_INTERNAL</link>
54
#define <link linkend="G-LIKELY:CAPS">G_LIKELY</link> (expr)
55
#define <link linkend="G-UNLIKELY:CAPS">G_UNLIKELY</link> (expr)
57
#define <link linkend="G-STRLOC:CAPS">G_STRLOC</link>
58
#define <link linkend="G-STRFUNC:CAPS">G_STRFUNC</link>
60
#define <link linkend="G-GINT16-MODIFIER:CAPS">G_GINT16_MODIFIER</link>
61
#define <link linkend="G-GINT16-FORMAT:CAPS">G_GINT16_FORMAT</link>
62
#define <link linkend="G-GUINT16-FORMAT:CAPS">G_GUINT16_FORMAT</link>
63
#define <link linkend="G-GINT32-MODIFIER:CAPS">G_GINT32_MODIFIER</link>
64
#define <link linkend="G-GINT32-FORMAT:CAPS">G_GINT32_FORMAT</link>
65
#define <link linkend="G-GUINT32-FORMAT:CAPS">G_GUINT32_FORMAT</link>
66
#define <link linkend="G-GINT64-MODIFIER:CAPS">G_GINT64_MODIFIER</link>
67
#define <link linkend="G-GINT64-FORMAT:CAPS">G_GINT64_FORMAT</link>
68
#define <link linkend="G-GUINT64-FORMAT:CAPS">G_GUINT64_FORMAT</link>
69
#define <link linkend="G-GSIZE-MODIFIER:CAPS">G_GSIZE_MODIFIER</link>
70
#define <link linkend="G-GSIZE-FORMAT:CAPS">G_GSIZE_FORMAT</link>
71
#define <link linkend="G-GSSIZE-FORMAT:CAPS">G_GSSIZE_FORMAT</link>
84
<refsect1 role="desc">
85
<title role="desc.title">Description</title>
87
These macros provide more specialized features which are not needed so often
88
by application programmers.
92
<refsect1 role="details">
93
<title role="details.title">Details</title>
95
<title><anchor id="G-INLINE-FUNC:CAPS" role="macro"/>G_INLINE_FUNC</title>
96
<indexterm><primary>G_INLINE_FUNC</primary></indexterm><programlisting>#define G_INLINE_FUNC</programlisting>
98
This macro is used to export function prototypes so they can be linked
99
with an external version when no inlining is performed. The file which
100
implements the functions should define <link linkend="G-IMPLEMENTS-INLINES:CAPS"><literal>G_IMPLEMENTS_INLINES</literal></link>
101
before including the headers which contain <link linkend="G-INLINE-FUNC:CAPS"><literal>G_INLINE_FUNC</literal></link> declarations.
102
Since inlining is very compiler-dependent using these macros correctly
103
is very difficult. Their use is strongly discouraged.
106
This macro is often mistaken for a replacement for the inline keyword;
107
inline is already declared in a portable manner in the glib headers
108
and can be used normally.
111
<title><anchor id="G-STMT-START:CAPS" role="macro"/>G_STMT_START</title>
112
<indexterm><primary>G_STMT_START</primary></indexterm><programlisting>#define G_STMT_START</programlisting>
114
Used within multi-statement macros so that they can be used in places where
115
only one statement is expected by the compiler.
118
<title><anchor id="G-STMT-END:CAPS" role="macro"/>G_STMT_END</title>
119
<indexterm><primary>G_STMT_END</primary></indexterm><programlisting>#define G_STMT_END</programlisting>
121
Used within multi-statement macros so that they can be used in places where
122
only one statement is expected by the compiler.
125
<title><anchor id="G-BEGIN-DECLS:CAPS" role="macro"/>G_BEGIN_DECLS</title>
126
<indexterm><primary>G_BEGIN_DECLS</primary></indexterm><programlisting>#define G_BEGIN_DECLS</programlisting>
128
Used (along with <link linkend="G-END-DECLS:CAPS"><type>G_END_DECLS</type></link>) to bracket header files. If the
129
compiler in use is a C++ compiler, adds <literal>extern "C"</literal>
133
<title><anchor id="G-END-DECLS:CAPS" role="macro"/>G_END_DECLS</title>
134
<indexterm><primary>G_END_DECLS</primary></indexterm><programlisting>#define G_END_DECLS</programlisting>
136
Used (along with <link linkend="G-BEGIN-DECLS:CAPS"><type>G_BEGIN_DECLS</type></link>) to bracket header files. If the
137
compiler in use is a C++ compiler, adds <literal>extern "C"</literal>
141
<title><anchor id="G-N-ELEMENTS:CAPS" role="macro"/>G_N_ELEMENTS()</title>
142
<indexterm><primary>G_N_ELEMENTS</primary></indexterm><programlisting>#define G_N_ELEMENTS(arr) (sizeof (arr) / sizeof ((arr)[0]))
145
Determines the number of elements in an array. The array must be
146
declared so the compiler knows its size at compile-time; this
147
macro will not work on an array allocated on the heap, only static
148
arrays or arrays on the stack.
149
</para><variablelist role="params">
150
<varlistentry><term><parameter>arr</parameter> :</term>
151
<listitem><simpara>the array
154
</simpara></listitem></varlistentry>
155
</variablelist></refsect2>
157
<title><anchor id="G-VA-COPY:CAPS" role="macro"/>G_VA_COPY()</title>
158
<indexterm><primary>G_VA_COPY</primary></indexterm><programlisting>#define G_VA_COPY(ap1,ap2)</programlisting>
160
Portable way to copy <type>va_list</type> variables.
163
In order to use this function, you must include <filename>string.h</filename>
164
yourself, because this macro may use <function><link linkend="memmove"><function>memmove()</function></link></function> and GLib
165
does not include <function>string.h</function> for you.
166
</para><variablelist role="params">
167
<varlistentry><term><parameter>ap1</parameter> :</term>
168
<listitem><simpara>the <type>va_list</type> variable to place a copy of <parameter>ap2</parameter> in.
169
</simpara></listitem></varlistentry>
170
<varlistentry><term><parameter>ap2</parameter> :</term>
171
<listitem><simpara>a <type>va_list</type>.
174
</simpara></listitem></varlistentry>
175
</variablelist></refsect2>
177
<title><anchor id="G-STRINGIFY:CAPS" role="macro"/>G_STRINGIFY()</title>
178
<indexterm><primary>G_STRINGIFY</primary></indexterm><programlisting>#define G_STRINGIFY(macro_or_string) G_STRINGIFY_ARG (macro_or_string)
181
Accepts a macro or a string and converts it into a string.
182
</para><variablelist role="params">
183
<varlistentry><term><parameter>macro_or_string</parameter> :</term>
184
<listitem><simpara>a macro or a string.
187
</simpara></listitem></varlistentry>
188
</variablelist></refsect2>
190
<title><anchor id="G-GNUC-EXTENSION:CAPS" role="macro"/>G_GNUC_EXTENSION</title>
191
<indexterm><primary>G_GNUC_EXTENSION</primary></indexterm><programlisting>#define G_GNUC_EXTENSION</programlisting>
193
Expands to <literal>__extension__</literal> when <command>gcc</command> is
194
used as the compiler.
195
This simply tells <command>gcc</command> not to warn about the following non-standard code
196
when compiling with the <option>-pedantic</option> option.
199
<title><anchor id="G-GNUC-CONST:CAPS" role="macro"/>G_GNUC_CONST</title>
200
<indexterm><primary>G_GNUC_CONST</primary></indexterm><programlisting>#define G_GNUC_CONST</programlisting>
202
Expands to the GNU C <literal>const</literal> function attribute if the compiler is
203
<command>gcc</command>. Declaring a function as const enables better optimization of calls
204
to the function. A const function doesn't examine any values except its parameters, and has no
205
effects except its return value. See the GNU C documentation for details.
208
A function that has pointer arguments and examines the data pointed to
209
must <emphasis>not</emphasis> be declared const. Likewise, a function that
210
calls a non-const function usually must not be const. It doesn't make sense
211
for a const function to return void.
212
</para></note></refsect2>
214
<title><anchor id="G-GNUC-PURE:CAPS" role="macro"/>G_GNUC_PURE</title>
215
<indexterm><primary>G_GNUC_PURE</primary></indexterm><programlisting>#define G_GNUC_PURE</programlisting>
217
Expands to the GNU C <literal>pure</literal> function attribute if the compiler is
218
<command>gcc</command>. Declaring a function as pure enables better optimization of
219
calls to the function. A pure function has no effects except its return value and the
220
return value depends only on the parameters and/or global variables.
221
See the GNU C documentation for details.
224
<title><anchor id="G-GNUC-MALLOC:CAPS" role="macro" condition="since:2.6"/>G_GNUC_MALLOC</title>
225
<indexterm role="2.6"><primary>G_GNUC_MALLOC</primary></indexterm><programlisting>#define G_GNUC_MALLOC</programlisting>
227
Expands to the GNU C <literal>malloc</literal> function attribute if the compiler is
228
<command>gcc</command>. Declaring a function as malloc enables better optimization of the
229
function. A function can have the malloc attribute if it returns a pointer which is guaranteed
230
to not alias with any other pointer when the function returns (in practice, this means newly
232
See the GNU C documentation for details.
233
</para><para role="since">Since 2.6
238
<title><anchor id="G-GNUC-DEPRECATED:CAPS" role="macro" condition="since:2.2"/>G_GNUC_DEPRECATED</title>
239
<indexterm role="2.2"><primary>G_GNUC_DEPRECATED</primary></indexterm><programlisting>#define G_GNUC_DEPRECATED</programlisting>
241
Expands to the GNU C <literal>deprecated</literal> attribute if the compiler
242
is <command>gcc</command>.
243
It can be used to mark typedefs, variables and functions as deprecated.
244
When called with the <option>-Wdeprecated</option> option, the compiler will
245
generate warnings when deprecated interfaces are used.
246
See the GNU C documentation for details.
247
</para><para role="since">Since 2.2
252
<title><anchor id="G-GNUC-NORETURN:CAPS" role="macro"/>G_GNUC_NORETURN</title>
253
<indexterm><primary>G_GNUC_NORETURN</primary></indexterm><programlisting>#define G_GNUC_NORETURN</programlisting>
255
Expands to the GNU C <literal>noreturn</literal> function attribute if the
256
compiler is <command>gcc</command>. It is used for declaring functions which never return.
257
It enables optimization of the function, and avoids possible compiler
258
warnings. See the GNU C documentation for details.
261
<title><anchor id="G-GNUC-UNUSED:CAPS" role="macro"/>G_GNUC_UNUSED</title>
262
<indexterm><primary>G_GNUC_UNUSED</primary></indexterm><programlisting>#define G_GNUC_UNUSED</programlisting>
264
Expands to the GNU C <literal>unused</literal> function attribute if the compiler is
265
<command>gcc</command>. It is used for declaring functions which may never be used.
266
It avoids possible compiler warnings. See the GNU C documentation for details.
269
<title><anchor id="G-GNUC-PRINTF:CAPS" role="macro"/>G_GNUC_PRINTF()</title>
270
<indexterm><primary>G_GNUC_PRINTF</primary></indexterm><programlisting>#define G_GNUC_PRINTF( format_idx, arg_idx )</programlisting>
272
Expands to the GNU C <literal>format</literal> function attribute if the compiler is
273
<command>gcc</command>. This is used for declaring functions which take a variable number of
274
arguments, with the same syntax as <function><link linkend="printf"><function>printf()</function></link></function>.
275
It allows the compiler to type-check the arguments passed to the function.
276
See the GNU C documentation for details.
278
<informalexample><programlisting>
279
gint g_snprintf (gchar *string,
282
...) G_GNUC_PRINTF (3, 4);
283
</programlisting></informalexample><variablelist role="params">
284
<varlistentry><term><parameter>format_idx</parameter> :</term>
285
<listitem><simpara>the index of the argument corresponding to the format string.
286
(The arguments are numbered from 1).
287
</simpara></listitem></varlistentry>
288
<varlistentry><term><parameter>arg_idx</parameter> :</term>
289
<listitem><simpara>the index of the first of the format arguments.
292
</simpara></listitem></varlistentry>
293
</variablelist></refsect2>
295
<title><anchor id="G-GNUC-SCANF:CAPS" role="macro"/>G_GNUC_SCANF()</title>
296
<indexterm><primary>G_GNUC_SCANF</primary></indexterm><programlisting>#define G_GNUC_SCANF( format_idx, arg_idx )</programlisting>
298
Expands to the GNU C <literal>format</literal> function attribute if the compiler is <command>gcc</command>.
299
This is used for declaring functions which take a variable number of
300
arguments, with the same syntax as <function><link linkend="scanf"><function>scanf()</function></link></function>.
301
It allows the compiler to type-check the arguments passed to the function.
302
See the GNU C documentation for details.
303
</para><variablelist role="params">
304
<varlistentry><term><parameter>format_idx</parameter> :</term>
305
<listitem><simpara>the index of the argument corresponding to the format string.
306
(The arguments are numbered from 1).
307
</simpara></listitem></varlistentry>
308
<varlistentry><term><parameter>arg_idx</parameter> :</term>
309
<listitem><simpara>the index of the first of the format arguments.
312
</simpara></listitem></varlistentry>
313
</variablelist></refsect2>
315
<title><anchor id="G-GNUC-FORMAT:CAPS" role="macro"/>G_GNUC_FORMAT()</title>
316
<indexterm><primary>G_GNUC_FORMAT</primary></indexterm><programlisting>#define G_GNUC_FORMAT( arg_idx )</programlisting>
318
Expands to the GNU C <literal>format_arg</literal> function attribute if the compiler is <command>gcc</command>.
319
This function attribute specifies that a function takes a format
320
string for a <function><link linkend="printf"><function>printf()</function></link></function>, <function><link linkend="scanf"><function>scanf()</function></link></function>,
321
<function><link linkend="strftime"><function>strftime()</function></link></function> or <function><link linkend="strfmon"><function>strfmon()</function></link></function> style
322
function and modifies it, so that the result can be passed to a
323
<function><link linkend="printf"><function>printf()</function></link></function>, <function><link linkend="scanf"><function>scanf()</function></link></function>,
324
<function><link linkend="strftime"><function>strftime()</function></link></function> or <function><link linkend="strfmon"><function>strfmon()</function></link></function> style
325
function (with the remaining arguments to the format function the same as
326
they would have been for the unmodified string).
327
See the GNU C documentation for details.
329
<informalexample><programlisting>
330
gchar *g_dgettext (gchar *domain_name, gchar *msgid) G_GNUC_FORMAT (2);
331
</programlisting></informalexample><variablelist role="params">
332
<varlistentry><term><parameter>arg_idx</parameter> :</term>
333
<listitem><simpara>the index of the argument.
336
</simpara></listitem></varlistentry>
337
</variablelist></refsect2>
339
<title><anchor id="G-GNUC-NULL-TERMINATED:CAPS" role="macro"/>G_GNUC_NULL_TERMINATED</title>
340
<indexterm><primary>G_GNUC_NULL_TERMINATED</primary></indexterm><programlisting>#define G_GNUC_NULL_TERMINATED</programlisting>
342
Expands to the GNU C <literal>sentinel</literal> function attribute if the
343
compiler is <command>gcc</command>, or "" if it isn't. This function attribute
344
only applies to variadic functions and instructs the compiler to check that
345
the argument list is terminated with an explicit <link linkend="NULL:CAPS"><literal>NULL</literal></link>.
346
See the GNU C documentation for details.
349
Since: 2.8</refsect2>
351
<title><anchor id="G-GNUC-WARN-UNUSED-RESULT:CAPS" role="macro" condition="since:2.10"/>G_GNUC_WARN_UNUSED_RESULT</title>
352
<indexterm role="2.10"><primary>G_GNUC_WARN_UNUSED_RESULT</primary></indexterm><programlisting>#define G_GNUC_WARN_UNUSED_RESULT</programlisting>
354
Expands to the GNU C <literal>warn_unused_ersult</literal> function attribute
355
if the compiler is <command>gcc</command>, or "" if it isn't. This function
356
attribute makes the compiler emit a warning if the result of a function call
357
is ignored. See the GNU C documentation for details.
358
</para><para role="since">Since 2.10
363
<title><anchor id="G-GNUC-FUNCTION:CAPS" role="macro"/>G_GNUC_FUNCTION</title>
364
<indexterm><primary>G_GNUC_FUNCTION</primary></indexterm><programlisting>#define G_GNUC_FUNCTION</programlisting>
366
Expands to the GNU C <literal>__FUNCTION__</literal> variable if the
367
compiler is <command>gcc</command>, or "" if it isn't. The GNU C
368
<literal>__FUNCTION__</literal> variable contains the name of the
369
current function. See the GNU C documentation for details.
372
<title><anchor id="G-GNUC-PRETTY-FUNCTION:CAPS" role="macro"/>G_GNUC_PRETTY_FUNCTION</title>
373
<indexterm><primary>G_GNUC_PRETTY_FUNCTION</primary></indexterm><programlisting>#define G_GNUC_PRETTY_FUNCTION</programlisting>
375
Expands to the GNU C <literal>__PRETTY_FUNCTION__</literal> variable
376
if the compiler is <command>gcc</command>, or "" if it isn't.
377
The GNU C <literal>__PRETTY_FUNCTION__</literal> variable contains the
378
name of the current function. For a C program this is the same as the
379
<literal>__FUNCTION__</literal> variable but for C++ it also includes
380
extra information such as the class and function prototype. See the
381
GNU C documentation for details.
384
<title><anchor id="G-GNUC-NO-INSTRUMENT:CAPS" role="macro"/>G_GNUC_NO_INSTRUMENT</title>
385
<indexterm><primary>G_GNUC_NO_INSTRUMENT</primary></indexterm><programlisting>#define G_GNUC_NO_INSTRUMENT</programlisting>
387
Expands to the GNU C <literal>no_instrument_function</literal> function
388
attribute if the compiler is <command>gcc</command>. Functions with this
389
attribute will not be
390
instrumented for profiling, when the compiler is called with the
391
<option>-finstrument-functions</option> option.
392
See the GNU C documentation for details.
395
<title><anchor id="G-HAVE-GNUC-VISIBILITY:CAPS" role="macro"/>G_HAVE_GNUC_VISIBILITY</title>
396
<indexterm><primary>G_HAVE_GNUC_VISIBILITY</primary></indexterm><programlisting>#define G_HAVE_GNUC_VISIBILITY 1
399
This macro is defined as 1 if the the compiler supports ELF visibility
400
attributes (currently only <command>gcc</command>).
403
Since: 2.6</refsect2>
405
<title><anchor id="G-GNUC-INTERNAL:CAPS" role="macro"/>G_GNUC_INTERNAL</title>
406
<indexterm><primary>G_GNUC_INTERNAL</primary></indexterm><programlisting>#define G_GNUC_INTERNAL</programlisting>
408
Expands to the GNU C <literal>visibility(hidden)</literal> attribute if the
409
compiler supports it (currently only <command>gcc</command>). This attribute
410
can be used for marking library functions as being used internally to the lib
411
only, to not create inefficient PLT entries. Note that static functions do not
412
need to be marked as internal in this way. See the GNU C documentation for details.
415
Since: 2.6</refsect2>
417
<title><anchor id="G-LIKELY:CAPS" role="macro" condition="since:2.2"/>G_LIKELY()</title>
418
<indexterm role="2.2"><primary>G_LIKELY</primary></indexterm><programlisting>#define G_LIKELY(expr)</programlisting>
420
Hints the compiler that the expression is likely to evaluate to a true
421
value. The compiler may use this information for optimizations.
423
<informalexample><programlisting>
424
if (G_LIKELY (random () != 1))
426
</programlisting></informalexample><variablelist role="params">
427
<varlistentry><term><parameter>expr</parameter> :</term>
428
<listitem><simpara>the expression
429
</simpara></listitem></varlistentry>
430
</variablelist><para role="since">Since 2.2
435
<title><anchor id="G-UNLIKELY:CAPS" role="macro" condition="since:2.2"/>G_UNLIKELY()</title>
436
<indexterm role="2.2"><primary>G_UNLIKELY</primary></indexterm><programlisting>#define G_UNLIKELY(expr)</programlisting>
438
Hints the compiler that the expression is unlikely to evaluate to a true
439
value. The compiler may use this information for optimizations.
441
<informalexample><programlisting>
442
if (G_UNLIKELY (random () == 1))
443
g_print ("a random one");
444
</programlisting></informalexample><variablelist role="params">
445
<varlistentry><term><parameter>expr</parameter> :</term>
446
<listitem><simpara>the expression
447
</simpara></listitem></varlistentry>
448
</variablelist><para role="since">Since 2.2
453
<title><anchor id="G-STRLOC:CAPS" role="macro"/>G_STRLOC</title>
454
<indexterm><primary>G_STRLOC</primary></indexterm><programlisting>#define G_STRLOC</programlisting>
456
Expands to a string identifying the current code position.
459
<title><anchor id="G-STRFUNC:CAPS" role="macro" condition="since:2.4"/>G_STRFUNC</title>
460
<indexterm role="2.4"><primary>G_STRFUNC</primary></indexterm><programlisting>#define G_STRFUNC</programlisting>
462
Expands to a string identifying the current function.
463
</para><para role="since">Since 2.4
468
<title><anchor id="G-GINT16-MODIFIER:CAPS" role="macro" condition="since:2.4"/>G_GINT16_MODIFIER</title>
469
<indexterm role="2.4"><primary>G_GINT16_MODIFIER</primary></indexterm><programlisting>#define G_GINT16_MODIFIER "h"
472
The platform dependent length modifier for constructing <link linkend="printf"><function>printf()</function></link> conversion
473
specifiers for values of type <link linkend="gint16"><type>gint16</type></link> or <link linkend="guint16"><type>guint16</type></link>. It is a string literal,
474
but doesn't include the percent-sign, such that you can add precision and
475
length modifiers between percent-sign and conversion specifier and append a
476
conversion specifier.
480
The following example prints "0x7b";
484
g_print ("%#" G_GINT16_MODIFIER "x", value);
487
</para><para role="since">Since 2.4
492
<title><anchor id="G-GINT16-FORMAT:CAPS" role="macro"/>G_GINT16_FORMAT</title>
493
<indexterm><primary>G_GINT16_FORMAT</primary></indexterm><programlisting>#define G_GINT16_FORMAT "hi"
496
This is the platform dependent conversion specifier for scanning and
497
printing values of type <link linkend="gint16"><type>gint16</type></link>. It is a string literal, but doesn't
498
include the percent-sign, such that you can add precision and length
499
modifiers between percent-sign and conversion specifier.
507
sscanf ("42", "%" G_GINT16_FORMAT, &in)
509
g_print ("%" G_GINT32_FORMAT, out);
514
<title><anchor id="G-GUINT16-FORMAT:CAPS" role="macro"/>G_GUINT16_FORMAT</title>
515
<indexterm><primary>G_GUINT16_FORMAT</primary></indexterm><programlisting>#define G_GUINT16_FORMAT "hu"
518
This is the platform dependent conversion specifier for scanning and
519
printing values of type <link linkend="guint16"><type>guint16</type></link>. See also <link linkend="G-GINT16-FORMAT:CAPS"><type>G_GINT16_FORMAT</type></link>.
522
<title><anchor id="G-GINT32-MODIFIER:CAPS" role="macro" condition="since:2.4"/>G_GINT32_MODIFIER</title>
523
<indexterm role="2.4"><primary>G_GINT32_MODIFIER</primary></indexterm><programlisting>#define G_GINT32_MODIFIER ""
526
The platform dependent length modifier for constructing <link linkend="printf"><function>printf()</function></link> conversion
527
specifiers for values of type <link linkend="gint32"><type>gint32</type></link> or <link linkend="guint32"><type>guint32</type></link>. See also <link linkend="G-GINT16-MODIFIER:CAPS"><type>G_GINT16_MODIFIER</type></link>.
528
</para><para role="since">Since 2.4
533
<title><anchor id="G-GINT32-FORMAT:CAPS" role="macro"/>G_GINT32_FORMAT</title>
534
<indexterm><primary>G_GINT32_FORMAT</primary></indexterm><programlisting>#define G_GINT32_FORMAT "i"
537
This is the platform dependent conversion specifier for scanning and
538
printing values of type <link linkend="gint32"><type>gint32</type></link>. See also <link linkend="G-GINT16-FORMAT:CAPS"><type>G_GINT16_FORMAT</type></link>.
541
<title><anchor id="G-GUINT32-FORMAT:CAPS" role="macro"/>G_GUINT32_FORMAT</title>
542
<indexterm><primary>G_GUINT32_FORMAT</primary></indexterm><programlisting>#define G_GUINT32_FORMAT "u"
545
This is the platform dependent conversion specifier for scanning and
546
printing values of type <link linkend="guint32"><type>guint32</type></link>. See also <link linkend="G-GINT16-FORMAT:CAPS"><type>G_GINT16_FORMAT</type></link>.
549
<title><anchor id="G-GINT64-MODIFIER:CAPS" role="macro" condition="since:2.4"/>G_GINT64_MODIFIER</title>
550
<indexterm role="2.4"><primary>G_GINT64_MODIFIER</primary></indexterm><programlisting>#define G_GINT64_MODIFIER "ll"
553
The platform dependent length modifier for constructing <link linkend="printf"><function>printf()</function></link> conversion
554
specifiers for values of type <link linkend="gint64"><type>gint64</type></link> or <link linkend="guint64"><type>guint64</type></link>. See also <link linkend="G-GINT16-MODIFIER:CAPS"><type>G_GINT16_MODIFIER</type></link>.
559
Some platforms do not support printing 64 bit integers,
560
even though the types are supported. On such platforms <link linkend="G-GINT64-MODIFIER:CAPS"><type>G_GINT64_MODIFIER</type></link>
563
</note><para role="since">Since 2.4
568
<title><anchor id="G-GINT64-FORMAT:CAPS" role="macro"/>G_GINT64_FORMAT</title>
569
<indexterm><primary>G_GINT64_FORMAT</primary></indexterm><programlisting>#define G_GINT64_FORMAT "lli"
572
This is the platform dependent conversion specifier for scanning and
573
printing values of type <link linkend="gint64"><type>gint64</type></link>. See also <link linkend="G-GINT16-FORMAT:CAPS"><type>G_GINT16_FORMAT</type></link>.
578
Some platforms do not support scanning and printing 64 bit integers,
579
even though the types are supported. On such platforms <link linkend="G-GINT64-FORMAT:CAPS"><type>G_GINT64_FORMAT</type></link>
580
is not defined. Note that <link linkend="scanf"><function>scanf()</function></link> may not support 64 bit integers, even
581
if <link linkend="G-GINT64-FORMAT:CAPS"><type>G_GINT64_FORMAT</type></link> is defined. Due to its weak error handling, <link linkend="scanf"><function>scanf()</function></link> is not
582
recommended for parsing anyway; consider using <link linkend="g-strtoull"><function>g_strtoull()</function></link> instead.
586
<title><anchor id="G-GUINT64-FORMAT:CAPS" role="macro"/>G_GUINT64_FORMAT</title>
587
<indexterm><primary>G_GUINT64_FORMAT</primary></indexterm><programlisting>#define G_GUINT64_FORMAT "llu"
590
This is the platform dependent conversion specifier for scanning and
591
printing values of type <link linkend="guint64"><type>guint64</type></link>. See also <link linkend="G-GINT16-FORMAT:CAPS"><type>G_GINT16_FORMAT</type></link>.
596
Some platforms do not support scanning and printing 64 bit integers,
597
even though the types are supported. On such platforms <link linkend="G-GUINT64-FORMAT:CAPS"><type>G_GUINT64_FORMAT</type></link>
598
is not defined. Note that <link linkend="scanf"><function>scanf()</function></link> may not support 64 bit integers, even
599
if <link linkend="G-GINT64-FORMAT:CAPS"><type>G_GINT64_FORMAT</type></link> is defined. Due to its weak error handling, <link linkend="scanf"><function>scanf()</function></link> is not
600
recommended for parsing anyway; consider using <link linkend="g-strtoull"><function>g_strtoull()</function></link> instead.
604
<title><anchor id="G-GSIZE-MODIFIER:CAPS" role="macro" condition="since:2.6"/>G_GSIZE_MODIFIER</title>
605
<indexterm role="2.6"><primary>G_GSIZE_MODIFIER</primary></indexterm><programlisting>#define G_GSIZE_MODIFIER ""
608
The platform dependent length modifier for constructing <link linkend="printf"><function>printf()</function></link> conversion
609
specifiers for values of type <link linkend="gsize"><type>gsize</type></link> or <link linkend="gssize"><type>gssize</type></link>. See also <link linkend="G-GINT16-MODIFIER:CAPS"><type>G_GINT16_MODIFIER</type></link>.
610
</para><para role="since">Since 2.6
615
<title><anchor id="G-GSIZE-FORMAT:CAPS" role="macro" condition="since:2.6"/>G_GSIZE_FORMAT</title>
616
<indexterm role="2.6"><primary>G_GSIZE_FORMAT</primary></indexterm><programlisting>#define G_GSIZE_FORMAT "u"
619
This is the platform dependent conversion specifier for scanning and
620
printing values of type <link linkend="gsize"><type>gsize</type></link>. See also <link linkend="G-GINT16-FORMAT:CAPS"><type>G_GINT16_FORMAT</type></link>.
621
</para><para role="since">Since 2.6
626
<title><anchor id="G-GSSIZE-FORMAT:CAPS" role="macro" condition="since:2.6"/>G_GSSIZE_FORMAT</title>
627
<indexterm role="2.6"><primary>G_GSSIZE_FORMAT</primary></indexterm><programlisting>#define G_GSSIZE_FORMAT "i"
630
This is the platform dependent conversion specifier for scanning and
631
printing values of type <link linkend="gssize"><type>gssize</type></link>. See also <link linkend="G-GINT16-FORMAT:CAPS"><type>G_GINT16_FORMAT</type></link>.
632
</para><para role="since">Since 2.6