~ubuntu-branches/ubuntu/utopic/glib2.0/utopic

« back to all changes in this revision

Viewing changes to docs/reference/glib/xml/macros_misc.xml

Tags: upstream-2.12.12
ImportĀ upstreamĀ versionĀ 2.12.12

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<refentry id="glib-Miscellaneous-Macros">
 
2
<refmeta>
 
3
<refentrytitle role="top_of_page">Miscellaneous Macros</refentrytitle>
 
4
<manvolnum>3</manvolnum>
 
5
<refmiscinfo>GLIB Library</refmiscinfo>
 
6
</refmeta>
 
7
 
 
8
<refnamediv>
 
9
<refname>Miscellaneous Macros</refname>
 
10
<refpurpose>specialized macros which are not used often.</refpurpose>
 
11
<!--[<xref linkend="desc" endterm="desc.title"/>]-->
 
12
</refnamediv>
 
13
 
 
14
<refsynopsisdiv role="synopsis">
 
15
<title role="synopsis.title">Synopsis</title>
 
16
 
 
17
<synopsis>
 
18
 
 
19
#include &lt;glib.h&gt;
 
20
 
 
21
 
 
22
#define             <link linkend="G-INLINE-FUNC:CAPS">G_INLINE_FUNC</link>
 
23
 
 
24
#define             <link linkend="G-STMT-START:CAPS">G_STMT_START</link>
 
25
#define             <link linkend="G-STMT-END:CAPS">G_STMT_END</link>
 
26
 
 
27
#define             <link linkend="G-BEGIN-DECLS:CAPS">G_BEGIN_DECLS</link>
 
28
#define             <link linkend="G-END-DECLS:CAPS">G_END_DECLS</link>
 
29
 
 
30
#define             <link linkend="G-N-ELEMENTS:CAPS">G_N_ELEMENTS</link>                        (arr)
 
31
 
 
32
#define             <link linkend="G-VA-COPY:CAPS">G_VA_COPY</link>                           (ap1,ap2)
 
33
 
 
34
#define             <link linkend="G-STRINGIFY:CAPS">G_STRINGIFY</link>                         (macro_or_string)
 
35
 
 
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>
 
53
 
 
54
#define             <link linkend="G-LIKELY:CAPS">G_LIKELY</link>                            (expr)
 
55
#define             <link linkend="G-UNLIKELY:CAPS">G_UNLIKELY</link>                          (expr)
 
56
 
 
57
#define             <link linkend="G-STRLOC:CAPS">G_STRLOC</link>
 
58
#define             <link linkend="G-STRFUNC:CAPS">G_STRFUNC</link>
 
59
 
 
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>
 
72
 
 
73
</synopsis>
 
74
</refsynopsisdiv>
 
75
 
 
76
 
 
77
 
 
78
 
 
79
 
 
80
 
 
81
 
 
82
 
 
83
 
 
84
<refsect1 role="desc">
 
85
<title role="desc.title">Description</title>
 
86
<para>
 
87
These macros provide more specialized features which are not needed so often
 
88
by application programmers.
 
89
</para>
 
90
</refsect1>
 
91
 
 
92
<refsect1 role="details">
 
93
<title role="details.title">Details</title>
 
94
<refsect2>
 
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>
 
97
<para>
 
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.
 
104
</para>
 
105
<para>
 
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.
 
109
</para></refsect2>
 
110
<refsect2>
 
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>
 
113
<para>
 
114
Used within multi-statement macros so that they can be used in places where
 
115
only one statement is expected by the compiler.
 
116
</para></refsect2>
 
117
<refsect2>
 
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>
 
120
<para>
 
121
Used within multi-statement macros so that they can be used in places where
 
122
only one statement is expected by the compiler.
 
123
</para></refsect2>
 
124
<refsect2>
 
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>
 
127
<para>
 
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> 
 
130
around the header.
 
131
</para></refsect2>
 
132
<refsect2>
 
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>
 
135
<para>
 
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> 
 
138
around the header.
 
139
</para></refsect2>
 
140
<refsect2>
 
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]))
 
143
</programlisting>
 
144
<para>
 
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>&nbsp;:</term>
 
151
<listitem><simpara>the array
 
152
 
 
153
 
 
154
</simpara></listitem></varlistentry>
 
155
</variablelist></refsect2>
 
156
<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>
 
159
<para>
 
160
Portable way to copy <type>va_list</type> variables.
 
161
</para>
 
162
<para>
 
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>&nbsp;:</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>&nbsp;:</term>
 
171
<listitem><simpara>a <type>va_list</type>.
 
172
 
 
173
 
 
174
</simpara></listitem></varlistentry>
 
175
</variablelist></refsect2>
 
176
<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)
 
179
</programlisting>
 
180
<para>
 
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>&nbsp;:</term>
 
184
<listitem><simpara>a macro or a string.
 
185
 
 
186
 
 
187
</simpara></listitem></varlistentry>
 
188
</variablelist></refsect2>
 
189
<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>
 
192
<para>
 
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.
 
197
</para></refsect2>
 
198
<refsect2>
 
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>
 
201
<para>
 
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. 
 
206
</para>
 
207
<note><para>
 
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>
 
213
<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>
 
216
<para>
 
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. 
 
222
</para></refsect2>
 
223
<refsect2>
 
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>
 
226
<para>
 
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 
 
231
allocated memory).  
 
232
See the GNU C documentation for details. 
 
233
</para><para role="since">Since 2.6
 
234
 
 
235
 
 
236
</para></refsect2>
 
237
<refsect2>
 
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>
 
240
<para>
 
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
 
248
 
 
249
 
 
250
</para></refsect2>
 
251
<refsect2>
 
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>
 
254
<para>
 
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. 
 
259
</para></refsect2>
 
260
<refsect2>
 
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>
 
263
<para>
 
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. 
 
267
</para></refsect2>
 
268
<refsect2>
 
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>
 
271
<para>
 
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. 
 
277
</para>
 
278
<informalexample><programlisting>
 
279
gint g_snprintf (gchar  *string,
 
280
                 gulong       n,
 
281
                 gchar const *format,
 
282
                 ...) G_GNUC_PRINTF (3, 4);
 
283
</programlisting></informalexample><variablelist role="params">
 
284
<varlistentry><term><parameter>format_idx</parameter>&nbsp;:</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>&nbsp;:</term>
 
289
<listitem><simpara>the index of the first of the format arguments.
 
290
 
 
291
 
 
292
</simpara></listitem></varlistentry>
 
293
</variablelist></refsect2>
 
294
<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>
 
297
<para>
 
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>&nbsp;:</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>&nbsp;:</term>
 
309
<listitem><simpara>the index of the first of the format arguments.
 
310
 
 
311
 
 
312
</simpara></listitem></varlistentry>
 
313
</variablelist></refsect2>
 
314
<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>
 
317
<para>
 
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. 
 
328
</para>
 
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>&nbsp;:</term>
 
333
<listitem><simpara>the index of the argument.
 
334
 
 
335
 
 
336
</simpara></listitem></varlistentry>
 
337
</variablelist></refsect2>
 
338
<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>
 
341
<para>
 
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. 
 
347
</para>
 
348
 
 
349
Since: 2.8</refsect2>
 
350
<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>
 
353
<para>
 
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
 
359
 
 
360
 
 
361
</para></refsect2>
 
362
<refsect2>
 
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>
 
365
<para>
 
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. 
 
370
</para></refsect2>
 
371
<refsect2>
 
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>
 
374
<para>
 
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. 
 
382
</para></refsect2>
 
383
<refsect2>
 
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>
 
386
<para>
 
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. 
 
393
</para></refsect2>
 
394
<refsect2>
 
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
 
397
</programlisting>
 
398
<para>
 
399
This macro is defined as 1 if the the compiler supports ELF visibility 
 
400
attributes (currently only <command>gcc</command>).
 
401
</para>
 
402
 
 
403
Since: 2.6</refsect2>
 
404
<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>
 
407
<para>
 
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. 
 
413
</para>
 
414
 
 
415
Since: 2.6</refsect2>
 
416
<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>
 
419
<para>
 
420
Hints the compiler that the expression is likely to evaluate to a true
 
421
value. The compiler may use this information for optimizations.
 
422
</para>
 
423
<informalexample><programlisting>
 
424
if (G_LIKELY (random () != 1))
 
425
  g_print ("not one");
 
426
</programlisting></informalexample><variablelist role="params">
 
427
<varlistentry><term><parameter>expr</parameter>&nbsp;:</term>
 
428
<listitem><simpara>the expression
 
429
</simpara></listitem></varlistentry>
 
430
</variablelist><para role="since">Since 2.2
 
431
 
 
432
 
 
433
</para></refsect2>
 
434
<refsect2>
 
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>
 
437
<para>
 
438
Hints the compiler that the expression is unlikely to evaluate to a true
 
439
value. The compiler may use this information for optimizations.
 
440
</para>
 
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>&nbsp;:</term>
 
446
<listitem><simpara>the expression
 
447
</simpara></listitem></varlistentry>
 
448
</variablelist><para role="since">Since 2.2
 
449
 
 
450
 
 
451
</para></refsect2>
 
452
<refsect2>
 
453
<title><anchor id="G-STRLOC:CAPS" role="macro"/>G_STRLOC</title>
 
454
<indexterm><primary>G_STRLOC</primary></indexterm><programlisting>#define             G_STRLOC</programlisting>
 
455
<para>
 
456
Expands to a string identifying the current code position. 
 
457
</para></refsect2>
 
458
<refsect2>
 
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>
 
461
<para>
 
462
Expands to a string identifying the current function. 
 
463
</para><para role="since">Since 2.4
 
464
 
 
465
 
 
466
</para></refsect2>
 
467
<refsect2>
 
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"
 
470
</programlisting>
 
471
<para>
 
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.
 
477
</para>
 
478
 
 
479
<para>
 
480
The following example prints "0x7b";
 
481
<informalexample>
 
482
<programlisting>
 
483
gint16 value = 123;
 
484
g_print ("%#" G_GINT16_MODIFIER "x", value);
 
485
</programlisting>
 
486
</informalexample>
 
487
</para><para role="since">Since 2.4
 
488
 
 
489
 
 
490
</para></refsect2>
 
491
<refsect2>
 
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"
 
494
</programlisting>
 
495
<para>
 
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.
 
500
</para>
 
501
 
 
502
<para>
 
503
<informalexample>
 
504
<programlisting>
 
505
gint16 in;
 
506
gint32 out;
 
507
sscanf ("42", "%" G_GINT16_FORMAT, &amp;in)
 
508
out = in * 1000;
 
509
g_print ("%" G_GINT32_FORMAT, out);
 
510
</programlisting>
 
511
</informalexample>
 
512
</para></refsect2>
 
513
<refsect2>
 
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"
 
516
</programlisting>
 
517
<para>
 
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>.
 
520
</para></refsect2>
 
521
<refsect2>
 
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 ""
 
524
</programlisting>
 
525
<para>
 
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
 
529
 
 
530
 
 
531
</para></refsect2>
 
532
<refsect2>
 
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"
 
535
</programlisting>
 
536
<para>
 
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>.
 
539
</para></refsect2>
 
540
<refsect2>
 
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"
 
543
</programlisting>
 
544
<para>
 
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>.
 
547
</para></refsect2>
 
548
<refsect2>
 
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"
 
551
</programlisting>
 
552
<para>
 
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>.
 
555
</para>
 
556
 
 
557
<note>
 
558
<para>
 
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>
 
561
is not defined.
 
562
</para>
 
563
</note><para role="since">Since 2.4
 
564
 
 
565
 
 
566
</para></refsect2>
 
567
<refsect2>
 
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"
 
570
</programlisting>
 
571
<para>
 
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>.
 
574
</para>
 
575
 
 
576
<note>
 
577
<para>
 
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.
 
583
</para>
 
584
</note></refsect2>
 
585
<refsect2>
 
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"
 
588
</programlisting>
 
589
<para>
 
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>.
 
592
</para>
 
593
 
 
594
<note>
 
595
<para>
 
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.
 
601
</para>
 
602
</note></refsect2>
 
603
<refsect2>
 
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 ""
 
606
</programlisting>
 
607
<para>
 
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
 
611
 
 
612
 
 
613
</para></refsect2>
 
614
<refsect2>
 
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"
 
617
</programlisting>
 
618
<para>
 
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
 
622
 
 
623
 
 
624
</para></refsect2>
 
625
<refsect2>
 
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"
 
628
</programlisting>
 
629
<para>
 
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
 
633
 
 
634
 
 
635
</para></refsect2>
 
636
 
 
637
</refsect1>
 
638
 
 
639
 
 
640
 
 
641
 
 
642
</refentry>