1
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
4
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
5
<title>Miscellaneous Macros</title>
6
<meta name="generator" content="DocBook XSL Stylesheets V1.72.0">
7
<link rel="start" href="index.html" title="GLib Reference Manual">
8
<link rel="up" href="glib-fundamentals.html" title="GLib Fundamentals">
9
<link rel="prev" href="glib-Numerical-Definitions.html" title="Numerical Definitions">
10
<link rel="next" href="glib-Atomic-Operations.html" title="Atomic Operations">
11
<meta name="generator" content="GTK-Doc V1.7 (XML mode)">
12
<link rel="stylesheet" href="style.css" type="text/css">
13
<link rel="chapter" href="glib.html" title="GLib Overview">
14
<link rel="chapter" href="glib-fundamentals.html" title="GLib Fundamentals">
15
<link rel="chapter" href="glib-core.html" title="GLib Core Application Support">
16
<link rel="chapter" href="glib-utilities.html" title="GLib Utilities">
17
<link rel="chapter" href="glib-data-types.html" title="GLib Data Types">
18
<link rel="chapter" href="tools.html" title="GLib Tools">
19
<link rel="index" href="ix01.html" title="Index">
20
<link rel="index" href="ix02.html" title="Index of deprecated symbols">
21
<link rel="index" href="ix03.html" title="Index of new symbols in 2.2">
22
<link rel="index" href="ix04.html" title="Index of new symbols in 2.4">
23
<link rel="index" href="ix05.html" title="Index of new symbols in 2.6">
24
<link rel="index" href="ix06.html" title="Index of new symbols in 2.8">
25
<link rel="index" href="ix07.html" title="Index of new symbols in 2.10">
26
<link rel="index" href="ix08.html" title="Index of new symbols in 2.12">
28
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
29
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
31
<td><a accesskey="p" href="glib-Numerical-Definitions.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
32
<td><a accesskey="u" href="glib-fundamentals.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
33
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
34
<th width="100%" align="center">GLib Reference Manual</th>
35
<td><a accesskey="n" href="glib-Atomic-Operations.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
37
<tr><td colspan="5" class="shortcuts"><nobr><a href="#id2711949" class="shortcut">Top</a>
39
<a href="#id2712329" class="shortcut">Description</a></nobr></td></tr>
41
<div class="refentry" lang="en">
42
<a name="glib-Miscellaneous-Macros"></a><div class="titlepage"></div>
43
<div class="refnamediv"><table width="100%"><tr>
46
<a name="id2711949"></a><span class="refentrytitle">Miscellaneous Macros</span>
48
<p>Miscellaneous Macros — specialized macros which are not used often.</p>
50
<td valign="top" align="right"></td>
52
<div class="refsynopsisdiv">
54
<pre class="synopsis">
56
#include <glib.h>
59
#define <a href="glib-Miscellaneous-Macros.html#G-INLINE-FUNC:CAPS">G_INLINE_FUNC</a>
61
#define <a href="glib-Miscellaneous-Macros.html#G-STMT-START:CAPS">G_STMT_START</a>
62
#define <a href="glib-Miscellaneous-Macros.html#G-STMT-END:CAPS">G_STMT_END</a>
64
#define <a href="glib-Miscellaneous-Macros.html#G-BEGIN-DECLS:CAPS">G_BEGIN_DECLS</a>
65
#define <a href="glib-Miscellaneous-Macros.html#G-END-DECLS:CAPS">G_END_DECLS</a>
67
#define <a href="glib-Miscellaneous-Macros.html#G-N-ELEMENTS:CAPS">G_N_ELEMENTS</a> (arr)
69
#define <a href="glib-Miscellaneous-Macros.html#G-VA-COPY:CAPS">G_VA_COPY</a> (ap1,ap2)
71
#define <a href="glib-Miscellaneous-Macros.html#G-STRINGIFY:CAPS">G_STRINGIFY</a> (macro_or_string)
73
#define <a href="glib-Miscellaneous-Macros.html#G-GNUC-EXTENSION:CAPS">G_GNUC_EXTENSION</a>
74
#define <a href="glib-Miscellaneous-Macros.html#G-GNUC-CONST:CAPS">G_GNUC_CONST</a>
75
#define <a href="glib-Miscellaneous-Macros.html#G-GNUC-PURE:CAPS">G_GNUC_PURE</a>
76
#define <a href="glib-Miscellaneous-Macros.html#G-GNUC-MALLOC:CAPS">G_GNUC_MALLOC</a>
77
#define <a href="glib-Miscellaneous-Macros.html#G-GNUC-DEPRECATED:CAPS">G_GNUC_DEPRECATED</a>
78
#define <a href="glib-Miscellaneous-Macros.html#G-GNUC-NORETURN:CAPS">G_GNUC_NORETURN</a>
79
#define <a href="glib-Miscellaneous-Macros.html#G-GNUC-UNUSED:CAPS">G_GNUC_UNUSED</a>
80
#define <a href="glib-Miscellaneous-Macros.html#G-GNUC-PRINTF:CAPS">G_GNUC_PRINTF</a> ( format_idx, arg_idx )
81
#define <a href="glib-Miscellaneous-Macros.html#G-GNUC-SCANF:CAPS">G_GNUC_SCANF</a> ( format_idx, arg_idx )
82
#define <a href="glib-Miscellaneous-Macros.html#G-GNUC-FORMAT:CAPS">G_GNUC_FORMAT</a> ( arg_idx )
83
#define <a href="glib-Miscellaneous-Macros.html#G-GNUC-NULL-TERMINATED:CAPS">G_GNUC_NULL_TERMINATED</a>
84
#define <a href="glib-Miscellaneous-Macros.html#G-GNUC-WARN-UNUSED-RESULT:CAPS">G_GNUC_WARN_UNUSED_RESULT</a>
85
#define <a href="glib-Miscellaneous-Macros.html#G-GNUC-FUNCTION:CAPS">G_GNUC_FUNCTION</a>
86
#define <a href="glib-Miscellaneous-Macros.html#G-GNUC-PRETTY-FUNCTION:CAPS">G_GNUC_PRETTY_FUNCTION</a>
87
#define <a href="glib-Miscellaneous-Macros.html#G-GNUC-NO-INSTRUMENT:CAPS">G_GNUC_NO_INSTRUMENT</a>
88
#define <a href="glib-Miscellaneous-Macros.html#G-HAVE-GNUC-VISIBILITY:CAPS">G_HAVE_GNUC_VISIBILITY</a>
89
#define <a href="glib-Miscellaneous-Macros.html#G-GNUC-INTERNAL:CAPS">G_GNUC_INTERNAL</a>
91
#define <a href="glib-Miscellaneous-Macros.html#G-LIKELY:CAPS">G_LIKELY</a> (expr)
92
#define <a href="glib-Miscellaneous-Macros.html#G-UNLIKELY:CAPS">G_UNLIKELY</a> (expr)
94
#define <a href="glib-Miscellaneous-Macros.html#G-STRLOC:CAPS">G_STRLOC</a>
95
#define <a href="glib-Miscellaneous-Macros.html#G-STRFUNC:CAPS">G_STRFUNC</a>
97
#define <a href="glib-Miscellaneous-Macros.html#G-GINT16-MODIFIER:CAPS">G_GINT16_MODIFIER</a>
98
#define <a href="glib-Miscellaneous-Macros.html#G-GINT16-FORMAT:CAPS">G_GINT16_FORMAT</a>
99
#define <a href="glib-Miscellaneous-Macros.html#G-GUINT16-FORMAT:CAPS">G_GUINT16_FORMAT</a>
100
#define <a href="glib-Miscellaneous-Macros.html#G-GINT32-MODIFIER:CAPS">G_GINT32_MODIFIER</a>
101
#define <a href="glib-Miscellaneous-Macros.html#G-GINT32-FORMAT:CAPS">G_GINT32_FORMAT</a>
102
#define <a href="glib-Miscellaneous-Macros.html#G-GUINT32-FORMAT:CAPS">G_GUINT32_FORMAT</a>
103
#define <a href="glib-Miscellaneous-Macros.html#G-GINT64-MODIFIER:CAPS">G_GINT64_MODIFIER</a>
104
#define <a href="glib-Miscellaneous-Macros.html#G-GINT64-FORMAT:CAPS">G_GINT64_FORMAT</a>
105
#define <a href="glib-Miscellaneous-Macros.html#G-GUINT64-FORMAT:CAPS">G_GUINT64_FORMAT</a>
106
#define <a href="glib-Miscellaneous-Macros.html#G-GSIZE-MODIFIER:CAPS">G_GSIZE_MODIFIER</a>
107
#define <a href="glib-Miscellaneous-Macros.html#G-GSIZE-FORMAT:CAPS">G_GSIZE_FORMAT</a>
108
#define <a href="glib-Miscellaneous-Macros.html#G-GSSIZE-FORMAT:CAPS">G_GSSIZE_FORMAT</a>
112
<div class="refsect1" lang="en">
113
<a name="id2712329"></a><h2>Description</h2>
115
These macros provide more specialized features which are not needed so often
116
by application programmers.
119
<div class="refsect1" lang="en">
120
<a name="id2712345"></a><h2>Details</h2>
121
<div class="refsect2" lang="en">
122
<a name="id2712356"></a><h3>
123
<a name="G-INLINE-FUNC:CAPS"></a>G_INLINE_FUNC</h3>
124
<a class="indexterm" name="id2712368"></a><pre class="programlisting">#define G_INLINE_FUNC</pre>
126
This macro is used to export function prototypes so they can be linked
127
with an external version when no inlining is performed. The file which
128
implements the functions should define <code class="literal">G_IMPLEMENTS_INLINES</code>
129
before including the headers which contain <a href="glib-Miscellaneous-Macros.html#G-INLINE-FUNC:CAPS"><code class="literal">G_INLINE_FUNC</code></a> declarations.
130
Since inlining is very compiler-dependent using these macros correctly
131
is very difficult. Their use is strongly discouraged.
134
This macro is often mistaken for a replacement for the inline keyword;
135
inline is already declared in a portable manner in the glib headers
136
and can be used normally.
140
<div class="refsect2" lang="en">
141
<a name="id2712418"></a><h3>
142
<a name="G-STMT-START:CAPS"></a>G_STMT_START</h3>
143
<a class="indexterm" name="id2712430"></a><pre class="programlisting">#define G_STMT_START</pre>
145
Used within multi-statement macros so that they can be used in places where
146
only one statement is expected by the compiler.
150
<div class="refsect2" lang="en">
151
<a name="id2712448"></a><h3>
152
<a name="G-STMT-END:CAPS"></a>G_STMT_END</h3>
153
<a class="indexterm" name="id2712461"></a><pre class="programlisting">#define G_STMT_END</pre>
155
Used within multi-statement macros so that they can be used in places where
156
only one statement is expected by the compiler.
160
<div class="refsect2" lang="en">
161
<a name="id2712478"></a><h3>
162
<a name="G-BEGIN-DECLS:CAPS"></a>G_BEGIN_DECLS</h3>
163
<a class="indexterm" name="id2712490"></a><pre class="programlisting">#define G_BEGIN_DECLS</pre>
165
Used (along with <a href="glib-Miscellaneous-Macros.html#G-END-DECLS:CAPS"><span class="type">G_END_DECLS</span></a>) to bracket header files. If the
166
compiler in use is a C++ compiler, adds <code class="literal">extern "C"</code>
171
<div class="refsect2" lang="en">
172
<a name="id2712522"></a><h3>
173
<a name="G-END-DECLS:CAPS"></a>G_END_DECLS</h3>
174
<a class="indexterm" name="id2712534"></a><pre class="programlisting">#define G_END_DECLS</pre>
176
Used (along with <a href="glib-Miscellaneous-Macros.html#G-BEGIN-DECLS:CAPS"><span class="type">G_BEGIN_DECLS</span></a>) to bracket header files. If the
177
compiler in use is a C++ compiler, adds <code class="literal">extern "C"</code>
182
<div class="refsect2" lang="en">
183
<a name="id2712565"></a><h3>
184
<a name="G-N-ELEMENTS:CAPS"></a>G_N_ELEMENTS()</h3>
185
<a class="indexterm" name="id2712578"></a><pre class="programlisting">#define G_N_ELEMENTS(arr) (sizeof (arr) / sizeof ((arr)[0]))
188
Determines the number of elements in an array. The array must be
189
declared so the compiler knows its size at compile-time; this
190
macro will not work on an array allocated on the heap, only static
191
arrays or arrays on the stack.
193
<div class="variablelist"><table border="0">
194
<col align="left" valign="top">
196
<td><span class="term"><em class="parameter"><code>arr</code></em> :</span></td>
205
<div class="refsect2" lang="en">
206
<a name="id2712616"></a><h3>
207
<a name="G-VA-COPY:CAPS"></a>G_VA_COPY()</h3>
208
<a class="indexterm" name="id2712629"></a><pre class="programlisting">#define G_VA_COPY(ap1,ap2)</pre>
210
Portable way to copy <span class="type">va_list</span> variables.
213
In order to use this function, you must include <code class="filename">string.h</code>
214
yourself, because this macro may use <code class="function"><code class="function">memmove()</code></code> and GLib
215
does not include <code class="function">string.h</code> for you.
217
<div class="variablelist"><table border="0">
218
<col align="left" valign="top">
221
<td><span class="term"><em class="parameter"><code>ap1</code></em> :</span></td>
222
<td>the <span class="type">va_list</span> variable to place a copy of <em class="parameter"><code>ap2</code></em> in.
226
<td><span class="term"><em class="parameter"><code>ap2</code></em> :</span></td>
227
<td>a <span class="type">va_list</span>.
236
<div class="refsect2" lang="en">
237
<a name="id2712725"></a><h3>
238
<a name="G-STRINGIFY:CAPS"></a>G_STRINGIFY()</h3>
239
<a class="indexterm" name="id2712737"></a><pre class="programlisting">#define G_STRINGIFY(macro_or_string) G_STRINGIFY_ARG (macro_or_string)
242
Accepts a macro or a string and converts it into a string.
244
<div class="variablelist"><table border="0">
245
<col align="left" valign="top">
247
<td><span class="term"><em class="parameter"><code>macro_or_string</code></em> :</span></td>
248
<td>a macro or a string.
256
<div class="refsect2" lang="en">
257
<a name="id2712773"></a><h3>
258
<a name="G-GNUC-EXTENSION:CAPS"></a>G_GNUC_EXTENSION</h3>
259
<a class="indexterm" name="id2712786"></a><pre class="programlisting">#define G_GNUC_EXTENSION</pre>
261
Expands to <code class="literal">__extension__</code> when <span><strong class="command">gcc</strong></span> is
262
used as the compiler.
263
This simply tells <span><strong class="command">gcc</strong></span> not to warn about the following non-standard code
264
when compiling with the <code class="option">-pedantic</code> option.
268
<div class="refsect2" lang="en">
269
<a name="id2712825"></a><h3>
270
<a name="G-GNUC-CONST:CAPS"></a>G_GNUC_CONST</h3>
271
<a class="indexterm" name="id2712837"></a><pre class="programlisting">#define G_GNUC_CONST</pre>
273
Expands to the GNU C <code class="literal">const</code> function attribute if the compiler is
274
<span><strong class="command">gcc</strong></span>. Declaring a function as const enables better optimization of calls
275
to the function. A const function doesn't examine any values except its parameters, and has no
276
effects except its return value. See the GNU C documentation for details.
278
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
279
<h3 class="title">Note</h3>
281
A function that has pointer arguments and examines the data pointed to
282
must <span class="emphasis"><em>not</em></span> be declared const. Likewise, a function that
283
calls a non-const function usually must not be const. It doesn't make sense
284
for a const function to return void.
289
<div class="refsect2" lang="en">
290
<a name="id2712881"></a><h3>
291
<a name="G-GNUC-PURE:CAPS"></a>G_GNUC_PURE</h3>
292
<a class="indexterm" name="id2712894"></a><pre class="programlisting">#define G_GNUC_PURE</pre>
294
Expands to the GNU C <code class="literal">pure</code> function attribute if the compiler is
295
<span><strong class="command">gcc</strong></span>. Declaring a function as pure enables better optimization of
296
calls to the function. A pure function has no effects except its return value and the
297
return value depends only on the parameters and/or global variables.
298
See the GNU C documentation for details.
302
<div class="refsect2" lang="en">
303
<a name="id2712925"></a><h3>
304
<a name="G-GNUC-MALLOC:CAPS"></a>G_GNUC_MALLOC</h3>
305
<a class="indexterm" name="id2712941"></a><pre class="programlisting">#define G_GNUC_MALLOC</pre>
307
Expands to the GNU C <code class="literal">malloc</code> function attribute if the compiler is
308
<span><strong class="command">gcc</strong></span>. Declaring a function as malloc enables better optimization of the
309
function. A function can have the malloc attribute if it returns a pointer which is guaranteed
310
to not alias with any other pointer when the function returns (in practice, this means newly
312
See the GNU C documentation for details.
314
<p class="since">Since 2.6
320
<div class="refsect2" lang="en">
321
<a name="id2712981"></a><h3>
322
<a name="G-GNUC-DEPRECATED:CAPS"></a>G_GNUC_DEPRECATED</h3>
323
<a class="indexterm" name="id2712997"></a><pre class="programlisting">#define G_GNUC_DEPRECATED</pre>
325
Expands to the GNU C <code class="literal">deprecated</code> attribute if the compiler
326
is <span><strong class="command">gcc</strong></span>.
327
It can be used to mark typedefs, variables and functions as deprecated.
328
When called with the <code class="option">-Wdeprecated</code> option, the compiler will
329
generate warnings when deprecated interfaces are used.
330
See the GNU C documentation for details.
332
<p class="since">Since 2.2
338
<div class="refsect2" lang="en">
339
<a name="id2713038"></a><h3>
340
<a name="G-GNUC-NORETURN:CAPS"></a>G_GNUC_NORETURN</h3>
341
<a class="indexterm" name="id2713052"></a><pre class="programlisting">#define G_GNUC_NORETURN</pre>
343
Expands to the GNU C <code class="literal">noreturn</code> function attribute if the
344
compiler is <span><strong class="command">gcc</strong></span>. It is used for declaring functions which never return.
345
It enables optimization of the function, and avoids possible compiler
346
warnings. See the GNU C documentation for details.
350
<div class="refsect2" lang="en">
351
<a name="id2713083"></a><h3>
352
<a name="G-GNUC-UNUSED:CAPS"></a>G_GNUC_UNUSED</h3>
353
<a class="indexterm" name="id2713095"></a><pre class="programlisting">#define G_GNUC_UNUSED</pre>
355
Expands to the GNU C <code class="literal">unused</code> function attribute if the compiler is
356
<span><strong class="command">gcc</strong></span>. It is used for declaring functions which may never be used.
357
It avoids possible compiler warnings. See the GNU C documentation for details.
361
<div class="refsect2" lang="en">
362
<a name="id2713125"></a><h3>
363
<a name="G-GNUC-PRINTF:CAPS"></a>G_GNUC_PRINTF()</h3>
364
<a class="indexterm" name="id2713138"></a><pre class="programlisting">#define G_GNUC_PRINTF( format_idx, arg_idx )</pre>
366
Expands to the GNU C <code class="literal">format</code> function attribute if the compiler is
367
<span><strong class="command">gcc</strong></span>. This is used for declaring functions which take a variable number of
368
arguments, with the same syntax as <code class="function"><code class="function">printf()</code></code>.
369
It allows the compiler to type-check the arguments passed to the function.
370
See the GNU C documentation for details.
372
<div class="informalexample"><pre class="programlisting">
373
gint g_snprintf (gchar *string,
376
...) G_GNUC_PRINTF (3, 4);
378
<div class="variablelist"><table border="0">
379
<col align="left" valign="top">
382
<td><span class="term"><em class="parameter"><code>format_idx</code></em> :</span></td>
383
<td>the index of the argument corresponding to the format string.
384
(The arguments are numbered from 1).
388
<td><span class="term"><em class="parameter"><code>arg_idx</code></em> :</span></td>
389
<td>the index of the first of the format arguments.
398
<div class="refsect2" lang="en">
399
<a name="id2713229"></a><h3>
400
<a name="G-GNUC-SCANF:CAPS"></a>G_GNUC_SCANF()</h3>
401
<a class="indexterm" name="id2713241"></a><pre class="programlisting">#define G_GNUC_SCANF( format_idx, arg_idx )</pre>
403
Expands to the GNU C <code class="literal">format</code> function attribute if the compiler is <span><strong class="command">gcc</strong></span>.
404
This is used for declaring functions which take a variable number of
405
arguments, with the same syntax as <code class="function"><code class="function">scanf()</code></code>.
406
It allows the compiler to type-check the arguments passed to the function.
407
See the GNU C documentation for details.
409
<div class="variablelist"><table border="0">
410
<col align="left" valign="top">
413
<td><span class="term"><em class="parameter"><code>format_idx</code></em> :</span></td>
414
<td>the index of the argument corresponding to the format string.
415
(The arguments are numbered from 1).
419
<td><span class="term"><em class="parameter"><code>arg_idx</code></em> :</span></td>
420
<td>the index of the first of the format arguments.
429
<div class="refsect2" lang="en">
430
<a name="id2713322"></a><h3>
431
<a name="G-GNUC-FORMAT:CAPS"></a>G_GNUC_FORMAT()</h3>
432
<a class="indexterm" name="id2713335"></a><pre class="programlisting">#define G_GNUC_FORMAT( arg_idx )</pre>
434
Expands to the GNU C <code class="literal">format_arg</code> function attribute if the compiler is <span><strong class="command">gcc</strong></span>.
435
This function attribute specifies that a function takes a format
436
string for a <code class="function"><code class="function">printf()</code></code>, <code class="function"><code class="function">scanf()</code></code>,
437
<code class="function"><code class="function">strftime()</code></code> or <code class="function"><code class="function">strfmon()</code></code> style
438
function and modifies it, so that the result can be passed to a
439
<code class="function"><code class="function">printf()</code></code>, <code class="function"><code class="function">scanf()</code></code>,
440
<code class="function"><code class="function">strftime()</code></code> or <code class="function"><code class="function">strfmon()</code></code> style
441
function (with the remaining arguments to the format function the same as
442
they would have been for the unmodified string).
443
See the GNU C documentation for details.
445
<div class="informalexample"><pre class="programlisting">
446
gchar *g_dgettext (gchar *domain_name, gchar *msgid) G_GNUC_FORMAT (2);
448
<div class="variablelist"><table border="0">
449
<col align="left" valign="top">
451
<td><span class="term"><em class="parameter"><code>arg_idx</code></em> :</span></td>
452
<td>the index of the argument.
460
<div class="refsect2" lang="en">
461
<a name="id2713505"></a><h3>
462
<a name="G-GNUC-NULL-TERMINATED:CAPS"></a>G_GNUC_NULL_TERMINATED</h3>
463
<a class="indexterm" name="id2713518"></a><pre class="programlisting">#define G_GNUC_NULL_TERMINATED</pre>
465
Expands to the GNU C <code class="literal">sentinel</code> function attribute if the
466
compiler is <span><strong class="command">gcc</strong></span>, or "" if it isn't. This function attribute
467
only applies to variadic functions and instructs the compiler to check that
468
the argument list is terminated with an explicit <a href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>.
469
See the GNU C documentation for details.
474
<div class="refsect2" lang="en">
475
<a name="id2713561"></a><h3>
476
<a name="G-GNUC-WARN-UNUSED-RESULT:CAPS"></a>G_GNUC_WARN_UNUSED_RESULT</h3>
477
<a class="indexterm" name="id2713578"></a><pre class="programlisting">#define G_GNUC_WARN_UNUSED_RESULT</pre>
479
Expands to the GNU C <code class="literal">warn_unused_ersult</code> function attribute
480
if the compiler is <span><strong class="command">gcc</strong></span>, or "" if it isn't. This function
481
attribute makes the compiler emit a warning if the result of a function call
482
is ignored. See the GNU C documentation for details.
484
<p class="since">Since 2.10
490
<div class="refsect2" lang="en">
491
<a name="id2713616"></a><h3>
492
<a name="G-GNUC-FUNCTION:CAPS"></a>G_GNUC_FUNCTION</h3>
493
<a class="indexterm" name="id2713630"></a><pre class="programlisting">#define G_GNUC_FUNCTION</pre>
495
Expands to the GNU C <code class="literal">__FUNCTION__</code> variable if the
496
compiler is <span><strong class="command">gcc</strong></span>, or "" if it isn't. The GNU C
497
<code class="literal">__FUNCTION__</code> variable contains the name of the
498
current function. See the GNU C documentation for details.
502
<div class="refsect2" lang="en">
503
<a name="id2713665"></a><h3>
504
<a name="G-GNUC-PRETTY-FUNCTION:CAPS"></a>G_GNUC_PRETTY_FUNCTION</h3>
505
<a class="indexterm" name="id2713677"></a><pre class="programlisting">#define G_GNUC_PRETTY_FUNCTION</pre>
507
Expands to the GNU C <code class="literal">__PRETTY_FUNCTION__</code> variable
508
if the compiler is <span><strong class="command">gcc</strong></span>, or "" if it isn't.
509
The GNU C <code class="literal">__PRETTY_FUNCTION__</code> variable contains the
510
name of the current function. For a C program this is the same as the
511
<code class="literal">__FUNCTION__</code> variable but for C++ it also includes
512
extra information such as the class and function prototype. See the
513
GNU C documentation for details.
517
<div class="refsect2" lang="en">
518
<a name="id2713722"></a><h3>
519
<a name="G-GNUC-NO-INSTRUMENT:CAPS"></a>G_GNUC_NO_INSTRUMENT</h3>
520
<a class="indexterm" name="id2713735"></a><pre class="programlisting">#define G_GNUC_NO_INSTRUMENT</pre>
522
Expands to the GNU C <code class="literal">no_instrument_function</code> function
523
attribute if the compiler is <span><strong class="command">gcc</strong></span>. Functions with this
524
attribute will not be
525
instrumented for profiling, when the compiler is called with the
526
<code class="option">-finstrument-functions</code> option.
527
See the GNU C documentation for details.
531
<div class="refsect2" lang="en">
532
<a name="id2713770"></a><h3>
533
<a name="G-HAVE-GNUC-VISIBILITY:CAPS"></a>G_HAVE_GNUC_VISIBILITY</h3>
534
<a class="indexterm" name="id2713783"></a><pre class="programlisting">#define G_HAVE_GNUC_VISIBILITY 1
537
This macro is defined as 1 if the the compiler supports ELF visibility
538
attributes (currently only <span><strong class="command">gcc</strong></span>).
543
<div class="refsect2" lang="en">
544
<a name="id2713807"></a><h3>
545
<a name="G-GNUC-INTERNAL:CAPS"></a>G_GNUC_INTERNAL</h3>
546
<a class="indexterm" name="id2713821"></a><pre class="programlisting">#define G_GNUC_INTERNAL</pre>
548
Expands to the GNU C <code class="literal">visibility(hidden)</code> attribute if the
549
compiler supports it (currently only <span><strong class="command">gcc</strong></span>). This attribute
550
can be used for marking library functions as being used internally to the lib
551
only, to not create inefficient PLT entries. Note that static functions do not
552
need to be marked as internal in this way. See the GNU C documentation for details.
557
<div class="refsect2" lang="en">
558
<a name="id2713855"></a><h3>
559
<a name="G-LIKELY:CAPS"></a>G_LIKELY()</h3>
560
<a class="indexterm" name="id2713870"></a><pre class="programlisting">#define G_LIKELY(expr)</pre>
562
Hints the compiler that the expression is likely to evaluate to a true
563
value. The compiler may use this information for optimizations.
565
<div class="informalexample"><pre class="programlisting">
566
if (G_LIKELY (random () != 1))
569
<div class="variablelist"><table border="0">
570
<col align="left" valign="top">
572
<td><span class="term"><em class="parameter"><code>expr</code></em> :</span></td>
577
<p class="since">Since 2.2
583
<div class="refsect2" lang="en">
584
<a name="id2713920"></a><h3>
585
<a name="G-UNLIKELY:CAPS"></a>G_UNLIKELY()</h3>
586
<a class="indexterm" name="id2713934"></a><pre class="programlisting">#define G_UNLIKELY(expr)</pre>
588
Hints the compiler that the expression is unlikely to evaluate to a true
589
value. The compiler may use this information for optimizations.
591
<div class="informalexample"><pre class="programlisting">
592
if (G_UNLIKELY (random () == 1))
593
g_print ("a random one");
595
<div class="variablelist"><table border="0">
596
<col align="left" valign="top">
598
<td><span class="term"><em class="parameter"><code>expr</code></em> :</span></td>
603
<p class="since">Since 2.2
609
<div class="refsect2" lang="en">
610
<a name="id2713985"></a><h3>
611
<a name="G-STRLOC:CAPS"></a>G_STRLOC</h3>
612
<a class="indexterm" name="id2713998"></a><pre class="programlisting">#define G_STRLOC</pre>
614
Expands to a string identifying the current code position.
618
<div class="refsect2" lang="en">
619
<a name="id2714014"></a><h3>
620
<a name="G-STRFUNC:CAPS"></a>G_STRFUNC</h3>
621
<a class="indexterm" name="id2714029"></a><pre class="programlisting">#define G_STRFUNC</pre>
623
Expands to a string identifying the current function.
625
<p class="since">Since 2.4
631
<div class="refsect2" lang="en">
632
<a name="id2714051"></a><h3>
633
<a name="G-GINT16-MODIFIER:CAPS"></a>G_GINT16_MODIFIER</h3>
634
<a class="indexterm" name="id2714067"></a><pre class="programlisting">#define G_GINT16_MODIFIER "h"
637
The platform dependent length modifier for constructing <code class="function">printf()</code> conversion
638
specifiers for values of type <a href="glib-Basic-Types.html#gint16"><span class="type">gint16</span></a> or <a href="glib-Basic-Types.html#guint16"><span class="type">guint16</span></a>. It is a string literal,
639
but doesn't include the percent-sign, such that you can add precision and
640
length modifiers between percent-sign and conversion specifier and append a
641
conversion specifier.
644
The following example prints "0x7b";
646
<div class="informalexample"><pre class="programlisting">
648
g_print ("%#" G_GINT16_MODIFIER "x", value);
652
<p class="since">Since 2.4
658
<div class="refsect2" lang="en">
659
<a name="id2714134"></a><h3>
660
<a name="G-GINT16-FORMAT:CAPS"></a>G_GINT16_FORMAT</h3>
661
<a class="indexterm" name="id2714148"></a><pre class="programlisting">#define G_GINT16_FORMAT "hi"
664
This is the platform dependent conversion specifier for scanning and
665
printing values of type <a href="glib-Basic-Types.html#gint16"><span class="type">gint16</span></a>. It is a string literal, but doesn't
666
include the percent-sign, such that you can add precision and length
667
modifiers between percent-sign and conversion specifier.
671
<div class="informalexample"><pre class="programlisting">
674
sscanf ("42", "%" G_GINT16_FORMAT, &in)
676
g_print ("%" G_GINT32_FORMAT, out);
682
<div class="refsect2" lang="en">
683
<a name="id2714190"></a><h3>
684
<a name="G-GUINT16-FORMAT:CAPS"></a>G_GUINT16_FORMAT</h3>
685
<a class="indexterm" name="id2714203"></a><pre class="programlisting">#define G_GUINT16_FORMAT "hu"
688
This is the platform dependent conversion specifier for scanning and
689
printing values of type <a href="glib-Basic-Types.html#guint16"><span class="type">guint16</span></a>. See also <a href="glib-Miscellaneous-Macros.html#G-GINT16-FORMAT:CAPS"><span class="type">G_GINT16_FORMAT</span></a>.
693
<div class="refsect2" lang="en">
694
<a name="id2714236"></a><h3>
695
<a name="G-GINT32-MODIFIER:CAPS"></a>G_GINT32_MODIFIER</h3>
696
<a class="indexterm" name="id2714252"></a><pre class="programlisting">#define G_GINT32_MODIFIER ""
699
The platform dependent length modifier for constructing <code class="function">printf()</code> conversion
700
specifiers for values of type <a href="glib-Basic-Types.html#gint32"><span class="type">gint32</span></a> or <a href="glib-Basic-Types.html#guint32"><span class="type">guint32</span></a>. See also <a href="glib-Miscellaneous-Macros.html#G-GINT16-MODIFIER:CAPS"><span class="type">G_GINT16_MODIFIER</span></a>.
702
<p class="since">Since 2.4
708
<div class="refsect2" lang="en">
709
<a name="id2714310"></a><h3>
710
<a name="G-GINT32-FORMAT:CAPS"></a>G_GINT32_FORMAT</h3>
711
<a class="indexterm" name="id2714323"></a><pre class="programlisting">#define G_GINT32_FORMAT "i"
714
This is the platform dependent conversion specifier for scanning and
715
printing values of type <a href="glib-Basic-Types.html#gint32"><span class="type">gint32</span></a>. See also <a href="glib-Miscellaneous-Macros.html#G-GINT16-FORMAT:CAPS"><span class="type">G_GINT16_FORMAT</span></a>.
719
<div class="refsect2" lang="en">
720
<a name="id2714356"></a><h3>
721
<a name="G-GUINT32-FORMAT:CAPS"></a>G_GUINT32_FORMAT</h3>
722
<a class="indexterm" name="id2714369"></a><pre class="programlisting">#define G_GUINT32_FORMAT "u"
725
This is the platform dependent conversion specifier for scanning and
726
printing values of type <a href="glib-Basic-Types.html#guint32"><span class="type">guint32</span></a>. See also <a href="glib-Miscellaneous-Macros.html#G-GINT16-FORMAT:CAPS"><span class="type">G_GINT16_FORMAT</span></a>.
730
<div class="refsect2" lang="en">
731
<a name="id2714403"></a><h3>
732
<a name="G-GINT64-MODIFIER:CAPS"></a>G_GINT64_MODIFIER</h3>
733
<a class="indexterm" name="id2714418"></a><pre class="programlisting">#define G_GINT64_MODIFIER "ll"
736
The platform dependent length modifier for constructing <code class="function">printf()</code> conversion
737
specifiers for values of type <a href="glib-Basic-Types.html#gint64"><span class="type">gint64</span></a> or <a href="glib-Basic-Types.html#guint64"><span class="type">guint64</span></a>. See also <a href="glib-Miscellaneous-Macros.html#G-GINT16-MODIFIER:CAPS"><span class="type">G_GINT16_MODIFIER</span></a>.
739
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
740
<h3 class="title">Note</h3>
742
Some platforms do not support printing 64 bit integers,
743
even though the types are supported. On such platforms <a href="glib-Miscellaneous-Macros.html#G-GINT64-MODIFIER:CAPS"><span class="type">G_GINT64_MODIFIER</span></a>
747
<p class="since">Since 2.4
753
<div class="refsect2" lang="en">
754
<a name="id2714494"></a><h3>
755
<a name="G-GINT64-FORMAT:CAPS"></a>G_GINT64_FORMAT</h3>
756
<a class="indexterm" name="id2714507"></a><pre class="programlisting">#define G_GINT64_FORMAT "lli"
759
This is the platform dependent conversion specifier for scanning and
760
printing values of type <a href="glib-Basic-Types.html#gint64"><span class="type">gint64</span></a>. See also <a href="glib-Miscellaneous-Macros.html#G-GINT16-FORMAT:CAPS"><span class="type">G_GINT16_FORMAT</span></a>.
762
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
763
<h3 class="title">Note</h3>
765
Some platforms do not support scanning and printing 64 bit integers,
766
even though the types are supported. On such platforms <a href="glib-Miscellaneous-Macros.html#G-GINT64-FORMAT:CAPS"><span class="type">G_GINT64_FORMAT</span></a>
767
is not defined. Note that <code class="function">scanf()</code> may not support 64 bit integers, even
768
if <a href="glib-Miscellaneous-Macros.html#G-GINT64-FORMAT:CAPS"><span class="type">G_GINT64_FORMAT</span></a> is defined. Due to its weak error handling, <code class="function">scanf()</code> is not
769
recommended for parsing anyway; consider using <code class="function">g_strtoull()</code> instead.
774
<div class="refsect2" lang="en">
775
<a name="id2714601"></a><h3>
776
<a name="G-GUINT64-FORMAT:CAPS"></a>G_GUINT64_FORMAT</h3>
777
<a class="indexterm" name="id2714614"></a><pre class="programlisting">#define G_GUINT64_FORMAT "llu"
780
This is the platform dependent conversion specifier for scanning and
781
printing values of type <a href="glib-Basic-Types.html#guint64"><span class="type">guint64</span></a>. See also <a href="glib-Miscellaneous-Macros.html#G-GINT16-FORMAT:CAPS"><span class="type">G_GINT16_FORMAT</span></a>.
783
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
784
<h3 class="title">Note</h3>
786
Some platforms do not support scanning and printing 64 bit integers,
787
even though the types are supported. On such platforms <a href="glib-Miscellaneous-Macros.html#G-GUINT64-FORMAT:CAPS"><span class="type">G_GUINT64_FORMAT</span></a>
788
is not defined. Note that <code class="function">scanf()</code> may not support 64 bit integers, even
789
if <a href="glib-Miscellaneous-Macros.html#G-GINT64-FORMAT:CAPS"><span class="type">G_GINT64_FORMAT</span></a> is defined. Due to its weak error handling, <code class="function">scanf()</code> is not
790
recommended for parsing anyway; consider using <code class="function">g_strtoull()</code> instead.
795
<div class="refsect2" lang="en">
796
<a name="id2714707"></a><h3>
797
<a name="G-GSIZE-MODIFIER:CAPS"></a>G_GSIZE_MODIFIER</h3>
798
<a class="indexterm" name="id2714722"></a><pre class="programlisting">#define G_GSIZE_MODIFIER ""
801
The platform dependent length modifier for constructing <code class="function">printf()</code> conversion
802
specifiers for values of type <a href="glib-Basic-Types.html#gsize"><span class="type">gsize</span></a> or <a href="glib-Basic-Types.html#gssize"><span class="type">gssize</span></a>. See also <a href="glib-Miscellaneous-Macros.html#G-GINT16-MODIFIER:CAPS"><span class="type">G_GINT16_MODIFIER</span></a>.
804
<p class="since">Since 2.6
810
<div class="refsect2" lang="en">
811
<a name="id2714780"></a><h3>
812
<a name="G-GSIZE-FORMAT:CAPS"></a>G_GSIZE_FORMAT</h3>
813
<a class="indexterm" name="id2714795"></a><pre class="programlisting">#define G_GSIZE_FORMAT "u"
816
This is the platform dependent conversion specifier for scanning and
817
printing values of type <a href="glib-Basic-Types.html#gsize"><span class="type">gsize</span></a>. See also <a href="glib-Miscellaneous-Macros.html#G-GINT16-FORMAT:CAPS"><span class="type">G_GINT16_FORMAT</span></a>.
819
<p class="since">Since 2.6
825
<div class="refsect2" lang="en">
826
<a name="id2714835"></a><h3>
827
<a name="G-GSSIZE-FORMAT:CAPS"></a>G_GSSIZE_FORMAT</h3>
828
<a class="indexterm" name="id2714851"></a><pre class="programlisting">#define G_GSSIZE_FORMAT "i"
831
This is the platform dependent conversion specifier for scanning and
832
printing values of type <a href="glib-Basic-Types.html#gssize"><span class="type">gssize</span></a>. See also <a href="glib-Miscellaneous-Macros.html#G-GINT16-FORMAT:CAPS"><span class="type">G_GINT16_FORMAT</span></a>.
834
<p class="since">Since 2.6