Buffers Files Tools Edit Search Mule Help Thu...
[glib.git] / docs / reference / glib / tmpl / macros_misc.sgml
blob1fd647e5fd6bb9b7790b0ef6faf483d27363c85f
1 <!-- ##### SECTION Title ##### -->
2 Miscellaneous Macros
4 <!-- ##### SECTION Short_Description ##### -->
5 specialised macros which are not used often.
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>
13 <!-- ##### SECTION See_Also ##### -->
14 <para>
16 </para>
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>
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>
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>
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>
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>
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>
66 @arr: the array
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>
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>.
84 <!-- ##### MACRO G_STRINGIFY ##### -->
85 <para>
87 </para>
89 @macro_or_string:
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>
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>
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>
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>
129 <!-- ##### MACRO G_GNUC_PURE ##### -->
130 <para>
132 </para>
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>
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.
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>
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.
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.
171 FIXME: I can't find this in my GNU C documentation. Take out?
172 </para>
174 @arg_idx: the index of the argument.
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>
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>
199 <!-- ##### MACRO G_STRLOC ##### -->
200 <para>
202 </para>
206 <!-- ##### MACRO G_GINT16_FORMAT ##### -->
207 <para>
208 This is the platform dependent conversion specifier for scanning and
209 printing values of type #gint16. It is a string literal, but doesn't
210 include the percent-sign, such that you can add precision and length
211 modifiers between percent-sign and conversion specifier.
212 </para>
214 <para>
215 <informalexample>
216 <programlisting>
217 gint16 in;
218 gint32 out;
219 sscanf ("42", "%" G_GINT16_FORMAT, &amp;in)
220 out = in * 1000;
221 g_print ("%" G_GINT32_FORMAT, out);
222 </programlisting>
223 </informalexample>
224 </para>
228 <!-- ##### MACRO G_GUINT16_FORMAT ##### -->
229 <para>
230 This is the platform dependent conversion specifier for scanning and
231 printing values of type #guint16. See also #G_GINT16_FORMAT.
232 </para>
236 <!-- ##### MACRO G_GINT32_FORMAT ##### -->
237 <para>
238 This is the platform dependent conversion specifier for scanning and
239 printing values of type #gint32. See also #G_GINT16_FORMAT.
240 </para>
244 <!-- ##### MACRO G_GUINT32_FORMAT ##### -->
245 <para>
246 This is the platform dependent conversion specifier for scanning and
247 printing values of type #guint32. See also #G_GINT16_FORMAT.
248 </para>
252 <!-- ##### MACRO G_GINT64_FORMAT ##### -->
253 <para>
254 This is the platform dependent conversion specifier for scanning and
255 printing values of type #gint64. See also #G_GINT16_FORMAT.
256 </para>
258 <note>
259 <para>
260 Some platforms do not support scanning and printing 64 bit integers,
261 even though the types are supported. On such platforms G_GINT64_FORMAT
262 is not defined.
263 </para>
264 </note>
268 <!-- ##### MACRO G_GUINT64_FORMAT ##### -->
269 <para>
270 This is the platform dependent conversion specifier for scanning and
271 printing values of type #guint64. See also #G_GINT16_FORMAT.
272 </para>
274 <note>
275 <para>
276 Some platforms do not support scanning and printing 64 bit integers,
277 even though the types are supported. On such platforms G_GUINT64_FORMAT
278 is not defined.
279 </para>
280 </note>