Update.
[platform/upstream/glib.git] / docs / reference / glib / tmpl / macros_misc.sgml
1 <!-- ##### SECTION Title ##### -->
2 Miscellaneous Macros
3
4 <!-- ##### SECTION Short_Description ##### -->
5 specialised macros which are not used often.
6
7 <!-- ##### SECTION Long_Description ##### -->
8 <para>
9 These macros provide more specialized features which are not needed so often
10 by application programmers.
11 </para>
12
13 <!-- ##### SECTION See_Also ##### -->
14 <para>
15
16 </para>
17
18 <!-- ##### MACRO G_INLINE_FUNC ##### -->
19 <para>
20 Used to declare inline functions. If inline functions are not supported on
21 the particular platform, the macro evaluates to the empty string.
22 </para>
23
24
25
26 <!-- ##### MACRO G_STMT_START ##### -->
27 <para>
28 Used within multi-statement macros so that they can be used in places where
29 only one statement is expected by the compiler.
30 </para>
31
32
33
34 <!-- ##### MACRO G_STMT_END ##### -->
35 <para>
36 Used within multi-statement macros so that they can be used in places where
37 only one statement is expected by the compiler.
38 </para>
39
40
41
42 <!-- ##### MACRO G_BEGIN_DECLS ##### -->
43 <para>
44 Used (along with #G_END_DECLS) to bracket header files. If the
45 compiler in use is a C++ compiler, adds 'extern "C"' around the header.
46 </para>
47
48
49
50 <!-- ##### MACRO G_END_DECLS ##### -->
51 <para>
52 Used (along with #G_BEGIN_DECLS) to bracket header files. If the
53 compiler in use is a C++ compiler, adds 'extern "C"' around the header.
54 </para>
55
56
57
58 <!-- ##### MACRO G_N_ELEMENTS ##### -->
59 <para>
60 Determines the number of elements in an array. The array must be
61 declared so the compiler knows its size at compile-time; this 
62 macro will not work on an array allocated on the heap, only static
63 arrays or arrays on the stack.
64 </para>
65
66 @arr: the array
67
68
69 <!-- ##### MACRO G_VA_COPY ##### -->
70 <para>
71 Portable way to copy <type>va_list</type> variables.
72 </para>
73 <para>
74 In order to use this function, you must include string.h yourself,
75 because this macro may use memmove() and GLib does not include
76 string.h for you.
77 </para>
78
79 <!-- # Unused Parameters # -->
80 @ap1: the <type>va_list</type> variable to place a copy of @ap2 in.
81 @ap2: a <type>va_list</type>.
82
83
84 <!-- ##### MACRO G_STRINGIFY ##### -->
85 <para>
86
87 </para>
88
89 @macro_or_string: 
90
91
92 <!-- ##### MACRO G_GNUC_EXTENSION ##### -->
93 <para>
94 Expands to "__extension__" when GNU C is used as the compiler.
95 This simply tells GNU C not to warn about the following non-standard code
96 when compiling with the -pedantic option.
97 </para>
98
99
100
101 <!-- ##### MACRO G_GNUC_CONST ##### -->
102 <para>
103 Expands to the GNU C const function attribute if the compiler is GNU C.
104 This enables optimization of the function.
105 See the GNU C documentation for details. 
106 </para>
107
108
109
110 <!-- ##### MACRO G_GNUC_NORETURN ##### -->
111 <para>
112 Expands to the GNU C noreturn function attribute if the compiler is GNU C.
113 It is used for declaring functions which never return.
114 It enables optimization of the function, and avoids possible compiler
115 warnings. See the GNU C documentation for details. 
116 </para>
117
118
119
120 <!-- ##### MACRO G_GNUC_UNUSED ##### -->
121 <para>
122 Expands to the GNU C unused function attribute if the compiler is GNU C.
123 It is used for declaring functions which may never be used.
124 It avoids possible compiler warnings. See the GNU C documentation for details. 
125 </para>
126
127
128
129 <!-- ##### MACRO G_GNUC_PURE ##### -->
130 <para>
131
132 </para>
133
134
135
136 <!-- ##### MACRO G_GNUC_PRINTF ##### -->
137 <para>
138 Expands to the GNU C format function attribute if the compiler is GNU C.
139 This is used for declaring functions which take a variable number of
140 arguments, with the same syntax as <function>printf()</function>.
141 It allows the compiler to type-check the arguments passed to the function.
142 See the GNU C documentation for details. 
143 </para>
144
145 @format_idx: the index of the argument corresponding to the format string.
146 (The arguments are numbered from 1).
147 @arg_idx: the index of the first of the format arguments.
148
149
150 <!-- ##### MACRO G_GNUC_SCANF ##### -->
151 <para>
152 Expands to the GNU C format function attribute if the compiler is GNU C.
153 This is used for declaring functions which take a variable number of
154 arguments, with the same syntax as <function>scanf()</function>.
155 It allows the compiler to type-check the arguments passed to the function.
156 See the GNU C documentation for details. 
157 </para>
158
159 @format_idx: the index of the argument corresponding to the format string.
160 (The arguments are numbered from 1).
161 @arg_idx: the index of the first of the format arguments.
162
163
164 <!-- ##### MACRO G_GNUC_FORMAT ##### -->
165 <para>
166 Expands to the GNU C format_arg function attribute if the compiler is GNU C.
167 This is used for declaring functions which take a variable number of
168 parameters, like <function>printf()</function> and
169 <function>scanf()</function>. See the GNU C documentation for details. 
170
171 FIXME: I can't find this in my GNU C documentation. Take out?
172 </para>
173
174 @arg_idx: the index of the argument.
175
176
177 <!-- ##### MACRO G_GNUC_FUNCTION ##### -->
178 <para>
179 Expands to the GNU C __FUNCTION__ variable if the compiler is GNU C,
180 or "" if it isn't.
181 The GNU C __FUNCTION__ variable contains the name of the current function.
182 See the GNU C documentation for details. 
183 </para>
184
185
186
187 <!-- ##### MACRO G_GNUC_PRETTY_FUNCTION ##### -->
188 <para>
189 Expands to the GNU C __PRETTY_FUNCTION__ variable if the compiler is GNU C,
190 or "" if it isn't.
191 The GNU C __PRETTY_FUNCTION__ variable contains the name of the current
192 function. For a C program this is the same as the __FUNCTION__ variable
193 but for C++ it also includes extra information such as the class
194 and function prototype. See the GNU C documentation for details. 
195 </para>
196
197
198
199 <!-- ##### MACRO G_GNUC_NO_INSTRUMENT ##### -->
200 <para>
201
202 </para>
203
204
205
206 <!-- ##### MACRO G_STRLOC ##### -->
207 <para>
208
209 </para>
210
211
212
213 <!-- ##### MACRO G_GINT16_FORMAT ##### -->
214 <para>
215 This is the platform dependent conversion specifier for scanning and
216 printing values of type #gint16. It is a string literal, but doesn't
217 include the percent-sign, such that you can add precision and length
218 modifiers between percent-sign and conversion specifier.
219 </para>
220
221 <para>
222 <informalexample>
223 <programlisting>
224 gint16 in;
225 gint32 out;
226 sscanf ("42", "%" G_GINT16_FORMAT, &amp;in)
227 out = in * 1000;
228 g_print ("%" G_GINT32_FORMAT, out);
229 </programlisting>
230 </informalexample>
231 </para>
232
233
234
235 <!-- ##### MACRO G_GUINT16_FORMAT ##### -->
236 <para>
237 This is the platform dependent conversion specifier for scanning and
238 printing values of type #guint16. See also #G_GINT16_FORMAT.
239 </para>
240
241
242
243 <!-- ##### MACRO G_GINT32_FORMAT ##### -->
244 <para>
245 This is the platform dependent conversion specifier for scanning and
246 printing values of type #gint32. See also #G_GINT16_FORMAT.
247 </para>
248
249
250
251 <!-- ##### MACRO G_GUINT32_FORMAT ##### -->
252 <para>
253 This is the platform dependent conversion specifier for scanning and
254 printing values of type #guint32. See also #G_GINT16_FORMAT.
255 </para>
256
257
258
259 <!-- ##### MACRO G_GINT64_FORMAT ##### -->
260 <para>
261 This is the platform dependent conversion specifier for scanning and
262 printing values of type #gint64. See also #G_GINT16_FORMAT.
263 </para>
264
265 <note>
266 <para>
267 Some platforms do not support scanning and printing 64 bit integers,
268 even though the types are supported. On such platforms G_GINT64_FORMAT
269 is not defined.
270 </para>
271 </note>
272
273
274
275 <!-- ##### MACRO G_GUINT64_FORMAT ##### -->
276 <para>
277 This is the platform dependent conversion specifier for scanning and
278 printing values of type #guint64. See also #G_GINT16_FORMAT.
279 </para>
280
281 <note>
282 <para>
283 Some platforms do not support scanning and printing 64 bit integers,
284 even though the types are supported. On such platforms G_GUINT64_FORMAT
285 is not defined.
286 </para>
287 </note>
288
289
290