f74f783cf4ead479671a5dfd1e6197a2ca99cc83
[platform/upstream/glib.git] / glib / docs.c
1 /*
2  * Copyright © 2011 Red Hat, Inc
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the licence, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  *
19  * Author: Matthias Clasen
20  */
21
22
23 /* This file collects documentation for macros, typedefs and
24  * the like, which have no good home in any of the 'real' source
25  * files.
26  */
27
28 /* Basic types {{{1 */
29
30 /**
31  * SECTION:types
32  * @title: Basic Types
33  * @short_description: standard GLib types, defined for ease-of-use
34  *     and portability
35  *
36  * GLib defines a number of commonly used types, which can be divided
37  * into 4 groups:
38  * - New types which are not part of standard C (but are defined in
39  *   various C standard library header files) - #gboolean, #gsize,
40  *   #gssize, #goffset, #gintptr, #guintptr.
41  * - Integer types which are guaranteed to be the same size across
42  *   all platforms - #gint8, #guint8, #gint16, #guint16, #gint32,
43  *   #guint32, #gint64, #guint64.
44  * - Types which are easier to use than their standard C counterparts -
45  *   #gpointer, #gconstpointer, #guchar, #guint, #gushort, #gulong.
46  * - Types which correspond exactly to standard C types, but are
47  *   included for completeness - #gchar, #gint, #gshort, #glong,
48  *   #gfloat, #gdouble.
49  *
50  * GLib also defines macros for the limits of some of the standard
51  * integer and floating point types, as well as macros for suitable
52  * printf() formats for these types.
53  */
54
55 /**
56  * gboolean:
57  *
58  * A standard boolean type.
59  * Variables of this type should only contain the value
60  * %TRUE or %FALSE.
61  */
62
63 /**
64  * gpointer:
65  *
66  * An untyped pointer.
67  * #gpointer looks better and is easier to use than void*.
68  */
69
70 /**
71  * gconstpointer:
72  *
73  * An untyped pointer to constant data.
74  * The data pointed to should not be changed.
75  *
76  * This is typically used in function prototypes to indicate
77  * that the data pointed to will not be altered by the function.
78  */
79
80 /**
81  * gchar:
82  *
83  * Corresponds to the standard C char type.
84  */
85
86 /**
87  * guchar:
88  *
89  * Corresponds to the standard C unsigned char type.
90  */
91
92 /**
93  * gint:
94  *
95  * Corresponds to the standard C int type.
96  * Values of this type can range from #G_MININT to #G_MAXINT.
97  */
98
99 /**
100  * G_MININT:
101  *
102  * The minimum value which can be held in a #gint.
103  */
104
105 /**
106  * G_MAXINT:
107  *
108  * The maximum value which can be held in a #gint.
109  */
110
111 /**
112  * guint:
113  *
114  * Corresponds to the standard C unsigned int type.
115  * Values of this type can range from 0 to #G_MAXUINT.
116  */
117
118 /**
119  * G_MAXUINT:
120  *
121  * The maximum value which can be held in a #guint.
122  */
123
124 /**
125  * gshort:
126  *
127  * Corresponds to the standard C short type.
128  * Values of this type can range from #G_MINSHORT to #G_MAXSHORT.
129  */
130
131 /**
132  * G_MINSHORT:
133  *
134  * The minimum value which can be held in a #gshort.
135  */
136
137 /**
138  * G_MAXSHORT:
139  *
140  * The maximum value which can be held in a #gshort.
141  */
142
143 /**
144  * gushort:
145  *
146  * Corresponds to the standard C unsigned short type.
147  * Values of this type can range from 0 to #G_MAXUSHORT.
148  */
149
150 /**
151  * G_MAXUSHORT:
152  *
153  * The maximum value which can be held in a #gushort.
154  */
155
156 /**
157  * glong:
158  *
159  * Corresponds to the standard C long type.
160  * Values of this type can range from #G_MINLONG to #G_MAXLONG.
161  */
162
163 /**
164  * G_MINLONG:
165  *
166  * The minimum value which can be held in a #glong.
167  */
168
169 /**
170  * G_MAXLONG:
171  *
172  * The maximum value which can be held in a #glong.
173  */
174
175 /**
176  * gulong:
177  *
178  * Corresponds to the standard C unsigned long type.
179  * Values of this type can range from 0 to #G_MAXULONG.
180  */
181
182 /**
183  * G_MAXULONG:
184  *
185  * The maximum value which can be held in a #gulong.
186  */
187
188 /**
189  * gint8:
190  *
191  * A signed integer guaranteed to be 8 bits on all platforms.
192  * Values of this type can range from #G_MININT8 (= -128) to
193  * #G_MAXINT8 (= 127).
194  */
195
196 /**
197  * G_MININT8:
198  *
199  * The minimum value which can be held in a #gint8.
200  *
201  * Since: 2.4
202  */
203
204 /**
205  * G_MAXINT8:
206  *
207  * The maximum value which can be held in a #gint8.
208  *
209  * Since: 2.4
210  */
211
212 /**
213  * guint8:
214  *
215  * An unsigned integer guaranteed to be 8 bits on all platforms.
216  * Values of this type can range from 0 to #G_MAXUINT8 (= 255).
217  */
218
219 /**
220  * G_MAXUINT8:
221  *
222  * The maximum value which can be held in a #guint8.
223  *
224  * Since: 2.4
225  */
226
227 /**
228  * gint16:
229  *
230  * A signed integer guaranteed to be 16 bits on all platforms.
231  * Values of this type can range from #G_MININT16 (= -32,768) to
232  * #G_MAXINT16 (= 32,767).
233  *
234  * To print or scan values of this type, use
235  * %G_GINT16_MODIFIER and/or %G_GINT16_FORMAT.
236  */
237
238 /**
239  * G_MININT16:
240  *
241  * The minimum value which can be held in a #gint16.
242  *
243  * Since: 2.4
244  */
245
246 /**
247  * G_MAXINT16:
248  *
249  * The maximum value which can be held in a #gint16.
250  *
251  * Since: 2.4
252  */
253
254 /**
255  * G_GINT16_MODIFIER:
256  *
257  * The platform dependent length modifier for conversion specifiers
258  * for scanning and printing values of type #gint16 or #guint16. It
259  * is a string literal, but doesn't include the percent-sign, such
260  * that you can add precision and length modifiers between percent-sign
261  * and conversion specifier and append a conversion specifier.
262  *
263  * The following example prints "0x7b";
264  * |[
265  * gint16 value = 123;
266  * g_print ("%#" G_GINT16_MODIFIER "x", value);
267  * ]|
268  *
269  * Since: 2.4
270  */
271
272 /**
273  * G_GINT16_FORMAT:
274  *
275  * This is the platform dependent conversion specifier for scanning and
276  * printing values of type #gint16. It is a string literal, but doesn't
277  * include the percent-sign, such that you can add precision and length
278  * modifiers between percent-sign and conversion specifier.
279  *
280  * |[
281  * gint16 in;
282  * gint32 out;
283  * sscanf ("42", "%" G_GINT16_FORMAT, &in)
284  * out = in * 1000;
285  * g_print ("%" G_GINT32_FORMAT, out);
286  * ]|
287  */
288
289 /**
290  * guint16:
291  *
292  * An unsigned integer guaranteed to be 16 bits on all platforms.
293  * Values of this type can range from 0 to #G_MAXUINT16 (= 65,535).
294  *
295  * To print or scan values of this type, use
296  * %G_GINT16_MODIFIER and/or %G_GUINT16_FORMAT.
297  */
298
299 /**
300  * G_MAXUINT16:
301  *
302  * The maximum value which can be held in a #guint16.
303  *
304  * Since: 2.4
305  */
306
307 /**
308  * G_GUINT16_FORMAT:
309  *
310  * This is the platform dependent conversion specifier for scanning
311  * and printing values of type #guint16. See also #G_GINT16_FORMAT
312  */
313
314 /**
315  * gint32:
316  *
317  * A signed integer guaranteed to be 32 bits on all platforms.
318  * Values of this type can range from #G_MININT32 (= -2,147,483,648)
319  * to #G_MAXINT32 (= 2,147,483,647).
320  *
321  * To print or scan values of this type, use
322  * %G_GINT32_MODIFIER and/or %G_GINT32_FORMAT.
323  */
324
325 /**
326  * G_MININT32:
327  *
328  * The minimum value which can be held in a #gint32.
329  *
330  * Since: 2.4
331  */
332
333 /**
334  * G_MAXINT32:
335  *
336  * The maximum value which can be held in a #gint32.
337  *
338  * Since: 2.4
339  */
340
341 /**
342  * G_GINT32_MODIFIER:
343  *
344  * The platform dependent length modifier for conversion specifiers
345  * for scanning and printing values of type #gint32 or #guint32. It
346  * is a string literal. See also #G_GINT16_MODIFIER.
347  *
348  * Since: 2.4
349  */
350
351 /**
352  * G_GINT32_FORMAT:
353  *
354  * This is the platform dependent conversion specifier for scanning
355  * and printing values of type #gint32. See also #G_GINT16_FORMAT.
356  */
357
358 /**
359  * guint32:
360  *
361  * An unsigned integer guaranteed to be 32 bits on all platforms.
362  * Values of this type can range from 0 to #G_MAXUINT32 (= 4,294,967,295).
363  *
364  * To print or scan values of this type, use
365  * %G_GINT32_MODIFIER and/or %G_GUINT32_FORMAT.
366  */
367
368 /**
369  * G_MAXUINT32:
370  *
371  * The maximum value which can be held in a #guint32.
372  *
373  * Since: 2.4
374  */
375
376 /**
377  * G_GUINT32_FORMAT:
378  *
379  * This is the platform dependent conversion specifier for scanning
380  * and printing values of type #guint32. See also #G_GINT16_FORMAT.
381  */
382
383 /**
384  * gint64:
385  *
386  * A signed integer guaranteed to be 64 bits on all platforms.
387  * Values of this type can range from #G_MININT64
388  * (= -9,223,372,036,854,775,808) to #G_MAXINT64
389  * (= 9,223,372,036,854,775,807).
390  *
391  * To print or scan values of this type, use
392  * %G_GINT64_MODIFIER and/or %G_GINT64_FORMAT.
393  */
394
395 /**
396  * G_MININT64:
397  *
398  * The minimum value which can be held in a #gint64.
399  */
400
401 /**
402  * G_MAXINT64:
403  *
404  * The maximum value which can be held in a #gint64.
405  */
406
407 /**
408  * G_GINT64_MODIFIER:
409  *
410  * The platform dependent length modifier for conversion specifiers
411  * for scanning and printing values of type #gint64 or #guint64.
412  * It is a string literal.
413  *
414  * <note><para>
415  * Some platforms do not support printing 64 bit integers, even
416  * though the types are supported. On such platforms #G_GINT64_MODIFIER
417  * is not defined.
418  * </para></note>
419  *
420  * Since: 2.4
421  */
422
423 /**
424  * G_GINT64_FORMAT:
425  *
426  * This is the platform dependent conversion specifier for scanning
427  * and printing values of type #gint64. See also #G_GINT16_FORMAT.
428  *
429  * <note><para>
430  * Some platforms do not support scanning and printing 64 bit integers,
431  * even though the types are supported. On such platforms #G_GINT64_FORMAT
432  * is not defined. Note that scanf() may not support 64 bit integers, even
433  * if #G_GINT64_FORMAT is defined. Due to its weak error handling, scanf()
434  * is not recommended for parsing anyway; consider using g_ascii_strtoull()
435  * instead.
436  * </para></note>
437  */
438
439 /**
440  * guint64:
441  *
442  * An unsigned integer guaranteed to be 64 bits on all platforms.
443  * Values of this type can range from 0 to #G_MAXUINT64
444  * (= 18,446,744,073,709,551,615).
445  *
446  * To print or scan values of this type, use
447  * %G_GINT64_MODIFIER and/or %G_GUINT64_FORMAT.
448  */
449
450 /**
451  * G_MAXUINT64:
452  *
453  * The maximum value which can be held in a #guint64.
454  */
455
456 /**
457  * G_GUINT64_FORMAT:
458  *
459  * This is the platform dependent conversion specifier for scanning
460  * and printing values of type #guint64. See also #G_GINT16_FORMAT.
461  *
462  * <note><para>
463  * Some platforms do not support scanning and printing 64 bit integers,
464  * even though the types are supported. On such platforms #G_GUINT64_FORMAT
465  * is not defined.  Note that scanf() may not support 64 bit integers, even
466  * if #G_GINT64_FORMAT is defined. Due to its weak error handling, scanf()
467  * is not recommended for parsing anyway; consider using g_ascii_strtoull()
468  * instead.
469  * </para></note>
470  */
471
472 /**
473  * G_GINT64_CONSTANT:
474  * @val: a literal integer value, e.g. 0x1d636b02300a7aa7
475  *
476  * This macro is used to insert 64-bit integer literals
477  * into the source code.
478  */
479
480 /**
481  * G_GUINT64_CONSTANT:
482  * @val: a literal integer value, e.g. 0x1d636b02300a7aa7U
483  *
484  * This macro is used to insert 64-bit unsigned integer
485  * literals into the source code.
486  *
487  * Since: 2.10
488  */
489
490 /**
491  * gfloat:
492  *
493  * Corresponds to the standard C float type.
494  * Values of this type can range from -#G_MAXFLOAT to #G_MAXFLOAT.
495  */
496
497 /**
498  * G_MINFLOAT:
499  *
500  * The minimum positive value which can be held in a #gfloat.
501  *
502  * If you are interested in the smallest value which can be held
503  * in a #gfloat, use -G_MAXFLOAT.
504  */
505
506 /**
507  * G_MAXFLOAT:
508  *
509  * The maximum value which can be held in a #gfloat.
510  */
511
512 /**
513  * gdouble:
514  *
515  * Corresponds to the standard C double type.
516  * Values of this type can range from -#G_MAXDOUBLE to #G_MAXDOUBLE.
517  */
518
519 /**
520  * G_MINDOUBLE:
521  *
522  * The minimum positive value which can be held in a #gdouble.
523  *
524  * If you are interested in the smallest value which can be held
525  * in a #gdouble, use -G_MAXDOUBLE.
526  */
527
528 /**
529  * G_MAXDOUBLE:
530  *
531  * The maximum value which can be held in a #gdouble.
532  */
533
534 /**
535  * gsize:
536  *
537  * An unsigned integer type of the result of the sizeof operator,
538  * corresponding to the size_t type defined in C99.
539  * This type is wide enough to hold the numeric value of a pointer,
540  * so it is usually 32bit wide on a 32bit platform and 64bit wide
541  * on a 64bit platform. Values of this type can range from 0 to
542  * #G_MAXSIZE.
543  *
544  * To print or scan values of this type, use
545  * %G_GSIZE_MODIFIER and/or %G_GSIZE_FORMAT.
546  */
547
548 /**
549  * G_MAXSIZE:
550  *
551  * The maximum value which can be held in a #gsize.
552  *
553  * Since: 2.4
554  */
555
556 /**
557  * G_GSIZE_MODIFIER:
558  *
559  * The platform dependent length modifier for conversion specifiers
560  * for scanning and printing values of type #gsize or #gssize. It
561  * is a string literal.
562  *
563  * Since: 2.6
564  */
565
566 /**
567  * G_GSIZE_FORMAT:
568  *
569  * This is the platform dependent conversion specifier for scanning
570  * and printing values of type #gsize. See also #G_GINT16_FORMAT.
571  *
572  * Since: 2.6
573  */
574
575 /**
576  * gssize:
577  *
578  * A signed variant of #gsize, corresponding to the
579  * ssize_t defined on most platforms.
580  * Values of this type can range from #G_MINSSIZE
581  * to #G_MAXSSIZE.
582  *
583  * To print or scan values of this type, use
584  * %G_GSIZE_MODIFIER and/or %G_GSSIZE_FORMAT.
585  */
586
587 /**
588  * G_MINSSIZE:
589  *
590  * The minimum value which can be held in a #gssize.
591  *
592  * Since: 2.14
593  */
594
595 /**
596  * G_MAXSSIZE:
597  *
598  * The maximum value which can be held in a #gssize.
599  *
600  * Since: 2.14
601  */
602
603 /**
604  * G_GSSIZE_FORMAT:
605  *
606  * This is the platform dependent conversion specifier for scanning
607  * and printing values of type #gssize. See also #G_GINT16_FORMAT.
608  *
609  * Since: 2.6
610  */
611
612 /**
613  * goffset:
614  *
615  * A signed integer type that is used for file offsets,
616  * corresponding to the C99 type off64_t.
617  * Values of this type can range from #G_MINOFFSET to
618  * #G_MAXOFFSET.
619  *
620  * To print or scan values of this type, use
621  * %G_GOFFSET_MODIFIER and/or %G_GOFFSET_FORMAT.
622  *
623  * Since: 2.14
624  */
625
626 /**
627  * G_MINOFFSET:
628  *
629  * The minimum value which can be held in a #goffset.
630  */
631
632 /**
633  * G_MAXOFFSET:
634  *
635  * The maximum value which can be held in a #goffset.
636  */
637
638 /**
639  * G_GOFFSET_MODIFIER:
640  *
641  * The platform dependent length modifier for conversion specifiers
642  * for scanning and printing values of type #goffset. It is a string
643  * literal. See also #G_GINT64_MODIFIER.
644  *
645  * Since: 2.20
646  */
647
648 /**
649  * G_GOFFSET_FORMAT:
650  *
651  * This is the platform dependent conversion specifier for scanning
652  * and printing values of type #goffset. See also #G_GINT64_FORMAT.
653  *
654  * Since: 2.20
655  */
656
657 /**
658  * G_GOFFSET_CONSTANT:
659  * @val: a literal integer value, e.g. 0x1d636b02300a7aa7
660  *
661  * This macro is used to insert #goffset 64-bit integer literals
662  * into the source code.
663  *
664  * See also #G_GINT64_CONSTANT.
665  *
666  * Since: 2.20
667  */
668
669 /**
670  * gintptr:
671  *
672  * Corresponds to the C99 type intptr_t,
673  * a signed integer type that can hold any pointer.
674  *
675  * To print or scan values of this type, use
676  * %G_GINTPTR_MODIFIER and/or %G_GINTPTR_FORMAT.
677  *
678  * Since: 2.18
679  */
680
681 /**
682  * G_GINTPTR_MODIFIER:
683  *
684  * The platform dependent length modifier for conversion specifiers
685  * for scanning and printing values of type #gintptr or #guintptr.
686  * It is a string literal.
687  *
688  * Since: 2.22
689  */
690
691 /**
692  * G_GINTPTR_FORMAT:
693  *
694  * This is the platform dependent conversion specifier for scanning
695  * and printing values of type #gintptr.
696  *
697  * Since: 2.22
698  */
699
700 /**
701  * guintptr:
702  *
703  * Corresponds to the C99 type uintptr_t,
704  * an unsigned integer type that can hold any pointer.
705  *
706  * To print or scan values of this type, use
707  * %G_GINTPTR_MODIFIER and/or %G_GUINTPTR_FORMAT.
708  *
709  * Since: 2.18
710  */
711
712 /**
713  * G_GUINTPTR_FORMAT:
714  *
715  * This is the platform dependent conversion specifier
716  * for scanning and printing values of type #guintptr.
717  *
718  * Since: 2.22
719  */
720
721 /* Type conversion {{{1 */
722
723 /**
724  * SECTION:type_conversion
725  * @title: Type Conversion Macros
726  * @short_description: portably storing integers in pointer variables
727  *
728  * Many times GLib, GTK+, and other libraries allow you to pass "user
729  * data" to a callback, in the form of a void pointer. From time to time
730  * you want to pass an integer instead of a pointer. You could allocate
731  * an integer, with something like:
732  * |[
733  *   int *ip = g_new (int, 1);
734  *   *ip = 42;
735  * ]|
736  * But this is inconvenient, and it's annoying to have to free the
737  * memory at some later time.
738  *
739  * Pointers are always at least 32 bits in size (on all platforms GLib
740  * intends to support). Thus you can store at least 32-bit integer values
741  * in a pointer value. Naively, you might try this, but it's incorrect:
742  * |[
743  *   gpointer p;
744  *   int i;
745  *   p = (void*) 42;
746  *   i = (int) p;
747  * ]|
748  * Again, that example was <emphasis>not</emphasis> correct, don't copy it.
749  * The problem is that on some systems you need to do this:
750  * |[
751  *   gpointer p;
752  *   int i;
753  *   p = (void*) (long) 42;
754  *   i = (int) (long) p;
755  * ]|
756  * The GLib macros GPOINTER_TO_INT(), GINT_TO_POINTER(), etc. take care
757  * to do the right thing on the every platform.
758  *
759  * <warning><para>You may not store pointers in integers. This is not
760  * portable in any way, shape or form. These macros <emphasis>only</emphasis>
761  * allow storing integers in pointers, and only preserve 32 bits of the
762  * integer; values outside the range of a 32-bit integer will be mangled.
763  * </para></warning>
764  */
765
766 /**
767  * GINT_TO_POINTER:
768  * @i: integer to stuff into a pointer
769  *
770  * Stuffs an integer into a pointer type.
771  *
772  * Remember, you may not store pointers in integers. This is not portable
773  * in any way, shape or form. These macros <emphasis>only</emphasis> allow
774  * storing integers in pointers, and only preserve 32 bits of the
775  * integer; values outside the range of a 32-bit integer will be mangled.
776  */
777
778 /**
779  * GPOINTER_TO_INT:
780  * @p: pointer containing an integer
781  *
782  * Extracts an integer from a pointer. The integer must have
783  * been stored in the pointer with GINT_TO_POINTER().
784  *
785  * Remember, you may not store pointers in integers. This is not portable
786  * in any way, shape or form. These macros <emphasis>only</emphasis> allow
787  * storing integers in pointers, and only preserve 32 bits of the
788  * integer; values outside the range of a 32-bit integer will be mangled.
789  */
790
791 /**
792  * GUINT_TO_POINTER:
793  * @u: unsigned integer to stuff into the pointer
794  *
795  * Stuffs an unsigned integer into a pointer type.
796  */
797
798 /**
799  * GPOINTER_TO_UINT:
800  * @p: pointer to extract an unsigned integer from
801  *
802  * Extracts an unsigned integer from a pointer. The integer must have
803  * been stored in the pointer with GUINT_TO_POINTER().
804  */
805
806 /**
807  * GSIZE_TO_POINTER:
808  * @s: #gsize to stuff into the pointer
809  *
810  * Stuffs a #gsize into a pointer type.
811  */
812
813 /**
814  * GPOINTER_TO_SIZE:
815  * @p: pointer to extract a #gsize from
816  *
817  * Extracts a #gsize from a pointer. The #gsize must have
818  * been stored in the pointer with GSIZE_TO_POINTER().
819  */
820
821 /* Byte order {{{1 */
822
823 /**
824  * SECTION:byte_order
825  * @title: Byte Order Macros
826  * @short_description: a portable way to convert between different byte orders
827  *
828  * These macros provide a portable way to determine the host byte order
829  * and to convert values between different byte orders.
830  *
831  * The byte order is the order in which bytes are stored to create larger
832  * data types such as the #gint and #glong values.
833  * The host byte order is the byte order used on the current machine.
834  *
835  * Some processors store the most significant bytes (i.e. the bytes that
836  * hold the largest part of the value) first. These are known as big-endian
837  * processors. Other processors (notably the x86 family) store the most
838  * significant byte last. These are known as little-endian processors.
839  *
840  * Finally, to complicate matters, some other processors store the bytes in
841  * a rather curious order known as PDP-endian. For a 4-byte word, the 3rd
842  * most significant byte is stored first, then the 4th, then the 1st and
843  * finally the 2nd.
844  *
845  * Obviously there is a problem when these different processors communicate
846  * with each other, for example over networks or by using binary file formats.
847  * This is where these macros come in. They are typically used to convert
848  * values into a byte order which has been agreed on for use when
849  * communicating between different processors. The Internet uses what is
850  * known as 'network byte order' as the standard byte order (which is in
851  * fact the big-endian byte order).
852  *
853  * Note that the byte order conversion macros may evaluate their arguments
854  * multiple times, thus you should not use them with arguments which have
855  * side-effects.
856  */
857
858 /**
859  * G_BYTE_ORDER:
860  *
861  * The host byte order.
862  * This can be either #G_LITTLE_ENDIAN or #G_BIG_ENDIAN (support for
863  * #G_PDP_ENDIAN may be added in future.)
864  */
865
866 /**
867  * G_LITTLE_ENDIAN:
868  *
869  * Specifies one of the possible types of byte order.
870  * See #G_BYTE_ORDER.
871  */
872
873 /**
874  * G_BIG_ENDIAN:
875  *
876  * Specifies one of the possible types of byte order.
877  * See #G_BYTE_ORDER.
878  */
879
880 /**
881  * G_PDP_ENDIAN:
882  *
883  * Specifies one of the possible types of byte order
884  * (currently unused). See #G_BYTE_ORDER.
885  */
886
887 /**
888  * g_htonl:
889  * @val: a 32-bit integer value in host byte order
890  *
891  * Converts a 32-bit integer value from host to network byte order.
892  *
893  * Returns: @val converted to network byte order
894  */
895
896 /**
897  * g_htons:
898  * @val: a 16-bit integer value in host byte order
899  *
900  * Converts a 16-bit integer value from host to network byte order.
901  *
902  * Returns: @val converted to network byte order
903  */
904
905 /**
906  * g_ntohl:
907  * @val: a 32-bit integer value in network byte order
908  *
909  * Converts a 32-bit integer value from network to host byte order.
910  *
911  * Returns: @val converted to host byte order.
912  */
913
914 /**
915  * g_ntohs:
916  * @val: a 16-bit integer value in network byte order
917  *
918  * Converts a 16-bit integer value from network to host byte order.
919  *
920  * Returns: @val converted to host byte order
921  */
922
923 /**
924  * GINT_FROM_BE:
925  * @val: a #gint value in big-endian byte order
926  *
927  * Converts a #gint value from big-endian to host byte order.
928  *
929  * Returns: @val converted to host byte order
930  */
931
932 /**
933  * GINT_FROM_LE:
934  * @val: a #gint value in little-endian byte order
935  *
936  * Converts a #gint value from little-endian to host byte order.
937  *
938  * Returns: @val converted to host byte order
939  */
940
941 /**
942  * GINT_TO_BE:
943  * @val: a #gint value in host byte order
944  *
945  * Converts a #gint value from host byte order to big-endian.
946  *
947  * Returns: @val converted to big-endian byte order
948  */
949
950 /**
951  * GINT_TO_LE:
952  * @val: a #gint value in host byte order
953  *
954  * Converts a #gint value from host byte order to little-endian.
955  *
956  * Returns: @val converted to little-endian byte order
957  */
958
959 /**
960  * GUINT_FROM_BE:
961  * @val: a #guint value in big-endian byte order
962  *
963  * Converts a #guint value from big-endian to host byte order.
964  *
965  * Returns: @val converted to host byte order
966  */
967
968 /**
969  * GUINT_FROM_LE:
970  * @val: a #guint value in little-endian byte order
971  *
972  * Converts a #guint value from little-endian to host byte order.
973  *
974  * Returns: @val converted to host byte order
975  */
976
977 /**
978  * GUINT_TO_BE:
979  * @val: a #guint value in host byte order
980  *
981  * Converts a #guint value from host byte order to big-endian.
982  *
983  * Returns: @val converted to big-endian byte order
984  */
985
986 /**
987  * GUINT_TO_LE:
988  * @val: a #guint value in host byte order
989  *
990  * Converts a #guint value from host byte order to little-endian.
991  *
992  * Returns: @val converted to little-endian byte order.
993  */
994
995 /**
996  * GLONG_FROM_BE:
997  * @val: a #glong value in big-endian byte order
998  *
999  * Converts a #glong value from big-endian to the host byte order.
1000  *
1001  * Returns: @val converted to host byte order
1002  */
1003
1004 /**
1005  * GLONG_FROM_LE:
1006  * @val: a #glong value in little-endian byte order
1007  *
1008  * Converts a #glong value from little-endian to host byte order.
1009  *
1010  * Returns: @val converted to host byte order
1011  */
1012
1013 /**
1014  * GLONG_TO_BE:
1015  * @val: a #glong value in host byte order
1016  *
1017  * Converts a #glong value from host byte order to big-endian.
1018  *
1019  * Returns: @val converted to big-endian byte order
1020  */
1021
1022 /**
1023  * GLONG_TO_LE:
1024  * @val: a #glong value in host byte order
1025  *
1026  * Converts a #glong value from host byte order to little-endian.
1027  *
1028  * Returns: @val converted to little-endian
1029  */
1030
1031 /**
1032  * GULONG_FROM_BE:
1033  * @val: a #gulong value in big-endian byte order
1034  *
1035  * Converts a #gulong value from big-endian to host byte order.
1036  *
1037  * Returns: @val converted to host byte order
1038  */
1039
1040 /**
1041  * GULONG_FROM_LE:
1042  * @val: a #gulong value in little-endian byte order
1043  *
1044  * Converts a #gulong value from little-endian to host byte order.
1045  *
1046  * Returns: @val converted to host byte order
1047  */
1048
1049 /**
1050  * GULONG_TO_BE:
1051  * @val: a #gulong value in host byte order
1052  *
1053  * Converts a #gulong value from host byte order to big-endian.
1054  *
1055  * Returns: @val converted to big-endian
1056  */
1057
1058 /**
1059  * GULONG_TO_LE:
1060  * @val: a #gulong value in host byte order
1061  *
1062  * Converts a #gulong value from host byte order to little-endian.
1063  *
1064  * Returns: @val converted to little-endian
1065  */
1066
1067 /**
1068  * GSIZE_FROM_BE:
1069  * @val: a #gsize value in big-endian byte order
1070  *
1071  * Converts a #gsize value from big-endian to the host byte order.
1072  *
1073  * Returns: @val converted to host byte order
1074  */
1075
1076 /**
1077  * GSIZE_FROM_LE:
1078  * @val: a #gsize value in little-endian byte order
1079  *
1080  * Converts a #gsize value from little-endian to host byte order.
1081  *
1082  * Returns: @val converted to host byte order
1083  */
1084
1085 /**
1086  * GSIZE_TO_BE:
1087  * @val: a #gsize value in host byte order
1088  *
1089  * Converts a #gsize value from host byte order to big-endian.
1090  *
1091  * Returns: @val converted to big-endian byte order
1092  */
1093
1094 /**
1095  * GSIZE_TO_LE:
1096  * @val: a #gsize value in host byte order
1097  *
1098  * Converts a #gsize value from host byte order to little-endian.
1099  *
1100  * Returns: @val converted to little-endian
1101  */
1102
1103 /**
1104  * GSSIZE_FROM_BE:
1105  * @val: a #gssize value in big-endian byte order
1106  *
1107  * Converts a #gssize value from big-endian to host byte order.
1108  *
1109  * Returns: @val converted to host byte order
1110  */
1111
1112 /**
1113  * GSSIZE_FROM_LE:
1114  * @val: a #gssize value in little-endian byte order
1115  *
1116  * Converts a #gssize value from little-endian to host byte order.
1117  *
1118  * Returns: @val converted to host byte order
1119  */
1120
1121 /**
1122  * GSSIZE_TO_BE:
1123  * @val: a #gssize value in host byte order
1124  *
1125  * Converts a #gssize value from host byte order to big-endian.
1126  *
1127  * Returns: @val converted to big-endian
1128  */
1129
1130 /**
1131  * GSSIZE_TO_LE:
1132  * @val: a #gssize value in host byte order
1133  *
1134  * Converts a #gssize value from host byte order to little-endian.
1135  *
1136  * Returns: @val converted to little-endian
1137  */
1138
1139 /**
1140  * GINT16_FROM_BE:
1141  * @val: a #gint16 value in big-endian byte order
1142  *
1143  * Converts a #gint16 value from big-endian to host byte order.
1144  *
1145  * Returns: @val converted to host byte order
1146  */
1147
1148 /**
1149  * GINT16_FROM_LE:
1150  * @val: a #gint16 value in little-endian byte order
1151  *
1152  * Converts a #gint16 value from little-endian to host byte order.
1153  *
1154  * Returns: @val converted to host byte order
1155  */
1156
1157 /**
1158  * GINT16_TO_BE:
1159  * @val: a #gint16 value in host byte order
1160  *
1161  * Converts a #gint16 value from host byte order to big-endian.
1162  *
1163  * Returns: @val converted to big-endian
1164  */
1165
1166 /**
1167  * GINT16_TO_LE:
1168  * @val: a #gint16 value in host byte order
1169  *
1170  * Converts a #gint16 value from host byte order to little-endian.
1171  *
1172  * Returns: @val converted to little-endian
1173  */
1174
1175 /**
1176  * GUINT16_FROM_BE:
1177  * @val: a #guint16 value in big-endian byte order
1178  *
1179  * Converts a #guint16 value from big-endian to host byte order.
1180  *
1181  * Returns: @val converted to host byte order
1182  */
1183
1184 /**
1185  * GUINT16_FROM_LE:
1186  * @val: a #guint16 value in little-endian byte order
1187  *
1188  * Converts a #guint16 value from little-endian to host byte order.
1189  *
1190  * Returns: @val converted to host byte order
1191  */
1192
1193 /**
1194  * GUINT16_TO_BE:
1195  * @val: a #guint16 value in host byte order
1196  *
1197  * Converts a #guint16 value from host byte order to big-endian.
1198  *
1199  * Returns: @val converted to big-endian
1200  */
1201
1202 /**
1203  * GUINT16_TO_LE:
1204  * @val: a #guint16 value in host byte order
1205  *
1206  * Converts a #guint16 value from host byte order to little-endian.
1207  *
1208  * Returns: @val converted to little-endian
1209  */
1210
1211 /**
1212  * GINT32_FROM_BE:
1213  * @val: a #gint32 value in big-endian byte order
1214  *
1215  * Converts a #gint32 value from big-endian to host byte order.
1216  *
1217  * Returns: @val converted to host byte order
1218  */
1219
1220 /**
1221  * GINT32_FROM_LE:
1222  * @val: a #gint32 value in little-endian byte order
1223  *
1224  * Converts a #gint32 value from little-endian to host byte order.
1225  *
1226  * Returns: @val converted to host byte order
1227  */
1228
1229 /**
1230  * GINT32_TO_BE:
1231  * @val: a #gint32 value in host byte order
1232  *
1233  * Converts a #gint32 value from host byte order to big-endian.
1234  *
1235  * Returns: @val converted to big-endian
1236  */
1237
1238 /**
1239  * GINT32_TO_LE:
1240  * @val: a #gint32 value in host byte order
1241  *
1242  * Converts a #gint32 value from host byte order to little-endian.
1243  *
1244  * Returns: @val converted to little-endian
1245  */
1246
1247 /**
1248  * GUINT32_FROM_BE:
1249  * @val: a #guint32 value in big-endian byte order
1250  *
1251  * Converts a #guint32 value from big-endian to host byte order.
1252  *
1253  * Returns: @val converted to host byte order
1254  */
1255
1256 /**
1257  * GUINT32_FROM_LE:
1258  * @val: a #guint32 value in little-endian byte order
1259  *
1260  * Converts a #guint32 value from little-endian to host byte order.
1261  *
1262  * Returns: @val converted to host byte order
1263  */
1264
1265 /**
1266  * GUINT32_TO_BE:
1267  * @val: a #guint32 value in host byte order
1268  *
1269  * Converts a #guint32 value from host byte order to big-endian.
1270  *
1271  * Returns: @val converted to big-endian
1272  */
1273
1274 /**
1275  * GUINT32_TO_LE:
1276  * @val: a #guint32 value in host byte order
1277  *
1278  * Converts a #guint32 value from host byte order to little-endian.
1279  *
1280  * Returns: @val converted to little-endian
1281  */
1282
1283 /**
1284  * GINT64_FROM_BE:
1285  * @val: a #gint64 value in big-endian byte order
1286  *
1287  * Converts a #gint64 value from big-endian to host byte order.
1288  *
1289  * Returns: @val converted to host byte order
1290  */
1291
1292 /**
1293  * GINT64_FROM_LE:
1294  * @val: a #gint64 value in little-endian byte order
1295  *
1296  * Converts a #gint64 value from little-endian to host byte order.
1297  *
1298  * Returns: @val converted to host byte order
1299  */
1300
1301 /**
1302  * GINT64_TO_BE:
1303  * @val: a #gint64 value in host byte order
1304  *
1305  * Converts a #gint64 value from host byte order to big-endian.
1306  *
1307  * Returns: @val converted to big-endian
1308  */
1309
1310 /**
1311  * GINT64_TO_LE:
1312  * @val: a #gint64 value in host byte order
1313  *
1314  * Converts a #gint64 value from host byte order to little-endian.
1315  *
1316  * Returns: @val converted to little-endian
1317  */
1318
1319 /**
1320  * GUINT64_FROM_BE:
1321  * @val: a #guint64 value in big-endian byte order
1322  *
1323  * Converts a #guint64 value from big-endian to host byte order.
1324  *
1325  * Returns: @val converted to host byte order
1326  */
1327
1328 /**
1329  * GUINT64_FROM_LE:
1330  * @val: a #guint64 value in little-endian byte order
1331  *
1332  * Converts a #guint64 value from little-endian to host byte order.
1333  *
1334  * Returns: @val converted to host byte order
1335  */
1336
1337 /**
1338  * GUINT64_TO_BE:
1339  * @val: a #guint64 value in host byte order
1340  *
1341  * Converts a #guint64 value from host byte order to big-endian.
1342  *
1343  * Returns: @val converted to big-endian
1344  */
1345
1346 /**
1347  * GUINT64_TO_LE:
1348  * @val: a #guint64 value in host byte order
1349  *
1350  * Converts a #guint64 value from host byte order to little-endian.
1351  *
1352  * Returns: @val converted to little-endian
1353  */
1354
1355 /**
1356  * GUINT16_SWAP_BE_PDP:
1357  * @val: a #guint16 value in big-endian or pdp-endian byte order
1358  *
1359  * Converts a #guint16 value between big-endian and pdp-endian byte order.
1360  * The conversion is symmetric so it can be used both ways.
1361  *
1362  * Returns: @val converted to the opposite byte order
1363  */
1364
1365 /**
1366  * GUINT16_SWAP_LE_BE:
1367  * @val: a #guint16 value in little-endian or big-endian byte order
1368  *
1369  * Converts a #guint16 value between little-endian and big-endian byte order.
1370  * The conversion is symmetric so it can be used both ways.
1371  *
1372  * Returns: @val converted to the opposite byte order
1373  */
1374
1375 /**
1376  * GUINT16_SWAP_LE_PDP:
1377  * @val: a #guint16 value in little-endian or pdp-endian byte order
1378  *
1379  * Converts a #guint16 value between little-endian and pdp-endian byte order.
1380  * The conversion is symmetric so it can be used both ways.
1381  *
1382  * Returns: @val converted to the opposite byte order
1383  */
1384
1385 /**
1386  * GUINT32_SWAP_BE_PDP:
1387  * @val: a #guint32 value in big-endian or pdp-endian byte order
1388  *
1389  * Converts a #guint32 value between big-endian and pdp-endian byte order.
1390  * The conversion is symmetric so it can be used both ways.
1391  *
1392  * Returns: @val converted to the opposite byte order
1393  */
1394
1395 /**
1396  * GUINT32_SWAP_LE_BE:
1397  * @val: a #guint32 value in little-endian or big-endian byte order
1398  *
1399  * Converts a #guint32 value between little-endian and big-endian byte order.
1400  * The conversion is symmetric so it can be used both ways.
1401  *
1402  * Returns: @val converted to the opposite byte order
1403  */
1404
1405 /**
1406  * GUINT32_SWAP_LE_PDP:
1407  * @val: a #guint32 value in little-endian or pdp-endian byte order
1408  *
1409  * Converts a #guint32 value between little-endian and pdp-endian byte order.
1410  * The conversion is symmetric so it can be used both ways.
1411  *
1412  * Returns: @val converted to the opposite byte order
1413  */
1414
1415 /**
1416  * GUINT64_SWAP_LE_BE:
1417  * @val: a #guint64 value in little-endian or big-endian byte order
1418  *
1419  * Converts a #guint64 value between little-endian and big-endian byte order.
1420  * The conversion is symmetric so it can be used both ways.
1421  *
1422  * Returns: @val converted to the opposite byte order
1423  */
1424
1425 /* Numerical Definitions {{{1 */
1426
1427 /**
1428  * SECTION:numerical
1429  * @title: Numerical Definitions
1430  * @short_description: mathematical constants, and floating point decomposition
1431  *
1432  * GLib offers mathematical constants such as #G_PI for the value of pi;
1433  * many platforms have these in the C library, but some don't, the GLib
1434  * versions always exist.
1435  *
1436  * The #GFloatIEEE754 and #GDoubleIEEE754 unions are used to access the
1437  * sign, mantissa and exponent of IEEE floats and doubles. These unions are
1438  * defined as appropriate for a given platform. IEEE floats and doubles are
1439  * supported (used for storage) by at least Intel, PPC and Sparc. See
1440  * <ulink url="http://en.wikipedia.org/wiki/IEEE_float">IEEE 754-2008</ulink>
1441  * for more information about IEEE number formats.
1442  */
1443
1444 /**
1445  * G_IEEE754_FLOAT_BIAS:
1446  *
1447  * The bias by which exponents in single-precision floats are offset.
1448  */
1449
1450 /**
1451  * G_IEEE754_DOUBLE_BIAS:
1452  *
1453  * The bias by which exponents in double-precision floats are offset.
1454  */
1455
1456 /**
1457  * GFloatIEEE754:
1458  * @v_float: the double value
1459  *
1460  * The #GFloatIEEE754 and #GDoubleIEEE754 unions are used to access the sign,
1461  * mantissa and exponent of IEEE floats and doubles. These unions are defined
1462  * as appropriate for a given platform. IEEE floats and doubles are supported
1463  * (used for storage) by at least Intel, PPC and Sparc.
1464  */
1465
1466 /**
1467  * GDoubleIEEE754:
1468  * @v_double: the double value
1469  *
1470  * The #GFloatIEEE754 and #GDoubleIEEE754 unions are used to access the sign,
1471  * mantissa and exponent of IEEE floats and doubles. These unions are defined
1472  * as appropriate for a given platform. IEEE floats and doubles are supported
1473  * (used for storage) by at least Intel, PPC and Sparc.
1474  */
1475
1476 /**
1477  * G_E:
1478  *
1479  * The base of natural logarithms.
1480  */
1481
1482 /**
1483  * G_LN2:
1484  *
1485  * The natural logarithm of 2.
1486  */
1487
1488 /**
1489  * G_LN10:
1490  *
1491  * The natural logarithm of 10.
1492  */
1493
1494 /**
1495  * G_PI:
1496  *
1497  * The value of pi (ratio of circle's circumference to its diameter).
1498  */
1499
1500 /**
1501  * G_PI_2:
1502  *
1503  * Pi divided by 2.
1504  */
1505
1506 /**
1507  * G_PI_4:
1508  *
1509  * Pi divided by 4.
1510  */
1511
1512 /**
1513  * G_SQRT2:
1514  *
1515  * The square root of two.
1516  */
1517
1518 /**
1519  * G_LOG_2_BASE_10:
1520  *
1521  * Multiplying the base 2 exponent by this number yields the base 10 exponent.
1522  */
1523
1524 /* Macros {{{1 */
1525
1526 /**
1527  * SECTION:macros
1528  * @title: Standard Macros
1529  * @short_description: commonly-used macros
1530  *
1531  * These macros provide a few commonly-used features.
1532  */
1533
1534 /**
1535  * G_OS_WIN32:
1536  *
1537  * This macro is defined only on Windows. So you can bracket
1538  * Windows-specific code in "&num;ifdef G_OS_WIN32".
1539  */
1540
1541 /**
1542  * G_OS_UNIX:
1543  *
1544  * This macro is defined only on UNIX. So you can bracket
1545  * UNIX-specific code in "&num;ifdef G_OS_UNIX".
1546  */
1547
1548 /**
1549  * G_DIR_SEPARATOR:
1550  *
1551  * The directory separator character.
1552  * This is '/' on UNIX machines and '\' under Windows.
1553  */
1554
1555 /**
1556  * G_DIR_SEPARATOR_S:
1557  *
1558  * The directory separator as a string.
1559  * This is "/" on UNIX machines and "\" under Windows.
1560  */
1561
1562 /**
1563  * G_IS_DIR_SEPARATOR:
1564  * @c: a character
1565  *
1566  * Checks whether a character is a directory
1567  * separator. It returns %TRUE for '/' on UNIX
1568  * machines and for '\' or '/' under Windows.
1569  *
1570  * Since: 2.6
1571  */
1572
1573 /**
1574  * G_SEARCHPATH_SEPARATOR:
1575  *
1576  * The search path separator character.
1577  * This is ':' on UNIX machines and ';' under Windows.
1578  */
1579
1580 /**
1581  * G_SEARCHPATH_SEPARATOR_S:
1582  *
1583  * The search path separator as a string.
1584  * This is ":" on UNIX machines and ";" under Windows.
1585  */
1586
1587 /**
1588  * TRUE:
1589  *
1590  * Defines the %TRUE value for the #gboolean type.
1591  */
1592
1593 /**
1594  * FALSE:
1595  *
1596  * Defines the %FALSE value for the #gboolean type.
1597  */
1598
1599 /**
1600  * NULL:
1601  *
1602  * Defines the standard %NULL pointer.
1603  */
1604
1605 /**
1606  * MIN:
1607  * @a: a numeric value
1608  * @b: a numeric value
1609  *
1610  * Calculates the minimum of @a and @b.
1611  *
1612  * Returns: the minimum of @a and @b.
1613  */
1614
1615 /**
1616  * MAX:
1617  * @a: a numeric value
1618  * @b: a numeric value
1619  *
1620  * Calculates the maximum of @a and @b.
1621  *
1622  * Returns: the maximum of @a and @b.
1623  */
1624
1625 /**
1626  * ABS:
1627  * @a: a numeric value
1628  *
1629  * Calculates the absolute value of @a.
1630  * The absolute value is simply the number with any negative sign taken away.
1631  *
1632  * For example,
1633  * - ABS(-10) is 10.
1634  * - ABS(10) is also 10.
1635  *
1636  * Returns: the absolute value of @a.
1637  */
1638
1639 /**
1640  * CLAMP:
1641  * @x: the value to clamp
1642  * @low: the minimum value allowed
1643  * @high: the maximum value allowed
1644  *
1645  * Ensures that @x is between the limits set by @low and @high. If @low is
1646  * greater than @high the result is undefined.
1647  *
1648  * For example,
1649  * - CLAMP(5, 10, 15) is 10.
1650  * - CLAMP(15, 5, 10) is 10.
1651  * - CLAMP(20, 15, 25) is 20.
1652  *
1653  * Returns: the value of @x clamped to the range between @low and @high
1654  */
1655
1656 /**
1657  * G_STRUCT_MEMBER:
1658  * @member_type: the type of the struct field
1659  * @struct_p: a pointer to a struct
1660  * @struct_offset: the offset of the field from the start of the struct,
1661  *     in bytes
1662  *
1663  * Returns a member of a structure at a given offset, using the given type.
1664  *
1665  * Returns: the struct member
1666  */
1667
1668 /**
1669  * G_STRUCT_MEMBER_P:
1670  * @struct_p: a pointer to a struct
1671  * @struct_offset: the offset from the start of the struct, in bytes
1672  *
1673  * Returns an untyped pointer to a given offset of a struct.
1674  *
1675  * Returns: an untyped pointer to @struct_p plus @struct_offset bytes
1676  */
1677
1678 /**
1679  * G_STRUCT_OFFSET:
1680  * @struct_type: a structure type, e.g. #GtkWidget
1681  * @member: a field in the structure, e.g. @window
1682  *
1683  * Returns the offset, in bytes, of a member of a struct.
1684  *
1685  * Returns: the offset of @member from the start of @struct_type
1686  */
1687
1688 /**
1689  * G_CONST_RETURN:
1690  *
1691  * If <literal>G_DISABLE_CONST_RETURNS</literal> is defined, this macro expands
1692  * to nothing. By default, the macro expands to <literal>const</literal>.
1693  * The macro should be used in place of <literal>const</literal> for
1694  * functions that return a value that should not be modified. The
1695  * purpose of this macro is to allow us to turn on <literal>const</literal>
1696  * for returned constant strings by default, while allowing programmers
1697  * who find that annoying to turn it off. This macro should only be used
1698  * for return values and for <emphasis>out</emphasis> parameters, it doesn't
1699  * make sense for <emphasis>in</emphasis> parameters.
1700  *
1701  * Deprecated: 2.30: API providers should replace all existing uses with
1702  *     <literal>const</literal> and API consumers should adjust their code
1703  *     accordingly
1704  */
1705
1706 /**
1707  * G_N_ELEMENTS:
1708  * @arr: the array
1709  *
1710  * Determines the number of elements in an array. The array must be
1711  * declared so the compiler knows its size at compile-time; this
1712  * macro will not work on an array allocated on the heap, only static
1713  * arrays or arrays on the stack.
1714  */
1715
1716 /* Miscellaneous Macros {{{1 */
1717
1718 /**
1719  * SECTION:macros_misc
1720  * @title: Miscellaneous Macros
1721  * @short_description: specialized macros which are not used often
1722  *
1723  * These macros provide more specialized features which are not
1724  * needed so often by application programmers.
1725  */
1726
1727 /**
1728  * G_INLINE_FUNC:
1729  *
1730  * This macro is used to export function prototypes so they can be linked
1731  * with an external version when no inlining is performed. The file which
1732  * implements the functions should define <literal>G_IMPLEMENTS_INLINES</literal>
1733  * before including the headers which contain %G_INLINE_FUNC declarations.
1734  * Since inlining is very compiler-dependent using these macros correctly
1735  * is very difficult. Their use is strongly discouraged.
1736  *
1737  * This macro is often mistaken for a replacement for the inline keyword;
1738  * inline is already declared in a portable manner in the GLib headers
1739  * and can be used normally.
1740  */
1741
1742 /**
1743  * G_STMT_START:
1744  *
1745  * Used within multi-statement macros so that they can be used in places
1746  * where only one statement is expected by the compiler.
1747  */
1748
1749 /**
1750  * G_STMT_END:
1751  *
1752  * Used within multi-statement macros so that they can be used in places
1753  * where only one statement is expected by the compiler.
1754  */
1755
1756 /**
1757  * G_BEGIN_DECLS:
1758  *
1759  * Used (along with #G_END_DECLS) to bracket header files. If the
1760  * compiler in use is a C++ compiler, adds <literal>extern "C"</literal>
1761  * around the header.
1762  */
1763
1764 /**
1765  * G_END_DECLS:
1766  *
1767  * Used (along with #G_BEGIN_DECLS) to bracket header files. If the
1768  * compiler in use is a C++ compiler, adds <literal>extern "C"</literal>
1769  * around the header.
1770  */
1771
1772 /**
1773  * G_VA_COPY:
1774  * @ap1: the va_list variable to place a copy of @ap2 in
1775  * @ap2: a va_list
1776  *
1777  * Portable way to copy va_list variables.
1778  *
1779  * In order to use this function, you must include string.h yourself,
1780  * because this macro may use memmove() and GLib does not include
1781  * string.h for you.
1782  */
1783
1784 /**
1785  * G_STRINGIFY:
1786  * @macro_or_string: a macro or a string
1787  *
1788  * Accepts a macro or a string and converts it into a string after
1789  * preprocessor argument expansion. For example, the following code:
1790  *
1791  * |[
1792  * #define AGE 27
1793  * const gchar *greeting = G_STRINGIFY (AGE) " today!";
1794  * ]|
1795  *
1796  * is transformed by the preprocessor into (code equivalent to):
1797  *
1798  * |[
1799  * const gchar *greeting = "27 today!";
1800  * ]|
1801  */
1802
1803 /**
1804  * G_PASTE:
1805  * @identifier1: an identifier
1806  * @identifier2: an identifier
1807  *
1808  * Yields a new preprocessor pasted identifier
1809  * <code>identifier1identifier2</code> from its expanded
1810  * arguments @identifier1 and @identifier2. For example,
1811  * the following code:
1812  * |[
1813  * #define GET(traveller,method) G_PASTE(traveller_get_, method) (traveller)
1814  * const gchar *name = GET (traveller, name);
1815  * const gchar *quest = GET (traveller, quest);
1816  * GdkColor *favourite = GET (traveller, favourite_colour);
1817  * ]|
1818  *
1819  * is transformed by the preprocessor into:
1820  * |[
1821  * const gchar *name = traveller_get_name (traveller);
1822  * const gchar *quest = traveller_get_quest (traveller);
1823  * GdkColor *favourite = traveller_get_favourite_colour (traveller);
1824  * ]|
1825  *
1826  * Since: 2.20
1827  */
1828
1829 /**
1830  * G_STATIC_ASSERT:
1831  * @expr: a constant expression
1832  *
1833  * The G_STATIC_ASSERT macro lets the programmer check
1834  * a condition at compile time, the condition needs to
1835  * be compile time computable. The macro can be used in
1836  * any place where a <literal>typedef</literal> is valid.
1837  *
1838  * <note><para>
1839  * A <literal>typedef</literal> is generally allowed in
1840  * exactly the same places that a variable declaration is
1841  * allowed. For this reason, you should not use
1842  * <literal>G_STATIC_ASSERT</literal> in the middle of
1843  * blocks of code.
1844  * </para></note>
1845  *
1846  * The macro should only be used once per source code line.
1847  *
1848  * Since: 2.20
1849  */
1850
1851 /**
1852  * G_STATIC_ASSERT_EXPR:
1853  * @expr: a constant expression
1854  *
1855  * The G_STATIC_ASSERT_EXPR macro lets the programmer check
1856  * a condition at compile time. The condition needs to be
1857  * compile time computable.
1858  *
1859  * Unlike <literal>G_STATIC_ASSERT</literal>, this macro
1860  * evaluates to an expression and, as such, can be used in
1861  * the middle of other expressions. Its value should be
1862  * ignored. This can be accomplished by placing it as
1863  * the first argument of a comma expression.
1864  *
1865  * |[
1866  * #define ADD_ONE_TO_INT(x) \
1867  *   (G_STATIC_ASSERT_EXPR(sizeof (x) == sizeof (int)), ((x) + 1))
1868  * ]|
1869  *
1870  * Since: 2.30
1871  */
1872
1873 /**
1874  * G_GNUC_EXTENSION:
1875  *
1876  * Expands to <literal>__extension__</literal> when <command>gcc</command>
1877  * is used as the compiler. This simply tells <command>gcc</command> not
1878  * to warn about the following non-standard code when compiling with the
1879  * <option>-pedantic</option> option.
1880  */
1881
1882 /**
1883  * G_GNUC_CONST:
1884  *
1885  * Expands to the GNU C <literal>const</literal> function attribute if
1886  * the compiler is <command>gcc</command>. Declaring a function as const
1887  * enables better optimization of calls to the function. A const function
1888  * doesn't examine any values except its parameters, and has no effects
1889  * except its return value.
1890  *
1891  * Place the attribute after the declaration, just before the semicolon.
1892  *
1893  * See the GNU C documentation for more details.
1894  *
1895  * <note><para>
1896  * A function that has pointer arguments and examines the data pointed to
1897  * must <emphasis>not</emphasis> be declared const. Likewise, a function
1898  * that calls a non-const function usually must not be const. It doesn't
1899  * make sense for a const function to return void.
1900  * </para></note>
1901  */
1902
1903 /**
1904  * G_GNUC_PURE:
1905  *
1906  * Expands to the GNU C <literal>pure</literal> function attribute if the
1907  * compiler is <command>gcc</command>. Declaring a function as pure enables
1908  * better optimization of calls to the function. A pure function has no
1909  * effects except its return value and the return value depends only on
1910  * the parameters and/or global variables.
1911  *
1912  * Place the attribute after the declaration, just before the semicolon.
1913  *
1914  * See the GNU C documentation for more details.
1915  */
1916
1917 /**
1918  * G_GNUC_MALLOC:
1919  *
1920  * Expands to the GNU C <literal>malloc</literal> function attribute if the
1921  * compiler is <command>gcc</command>. Declaring a function as malloc enables
1922  * better optimization of the function. A function can have the malloc
1923  * attribute if it returns a pointer which is guaranteed to not alias with
1924  * any other pointer when the function returns (in practice, this means newly
1925  * allocated memory).
1926  *
1927  * Place the attribute after the declaration, just before the semicolon.
1928  *
1929  * See the GNU C documentation for more details.
1930  *
1931  * Since: 2.6
1932  */
1933
1934 /**
1935  * G_GNUC_ALLOC_SIZE:
1936  * @x: the index of the argument specifying the allocation size
1937  *
1938  * Expands to the GNU C <literal>alloc_size</literal> function attribute
1939  * if the compiler is a new enough <command>gcc</command>. This attribute
1940  * tells the compiler that the function returns a pointer to memory of a
1941  * size that is specified by the @x<!-- -->th function parameter.
1942  *
1943  * Place the attribute after the function declaration, just before the
1944  * semicolon.
1945  *
1946  * See the GNU C documentation for more details.
1947  *
1948  * Since: 2.18
1949  */
1950
1951 /**
1952  * G_GNUC_ALLOC_SIZE2:
1953  * @x: the index of the argument specifying one factor of the allocation size
1954  * @y: the index of the argument specifying the second factor of the allocation size
1955  *
1956  * Expands to the GNU C <literal>alloc_size</literal> function attribute
1957  * if the compiler is a new enough <command>gcc</command>. This attribute
1958  * tells the compiler that the function returns a pointer to memory of a
1959  * size that is specified by the product of two function parameters.
1960  *
1961  * Place the attribute after the function declaration, just before the
1962  * semicolon.
1963  *
1964  * See the GNU C documentation for more details.
1965  *
1966  * Since: 2.18
1967  */
1968
1969 /**
1970  * G_GNUC_DEPRECATED:
1971  *
1972  * Expands to the GNU C <literal>deprecated</literal> attribute if the
1973  * compiler is <command>gcc</command>. It can be used to mark typedefs,
1974  * variables and functions as deprecated. When called with the
1975  * <option>-Wdeprecated-declarations</option> option, the compiler will
1976  * generate warnings when deprecated interfaces are used.
1977  *
1978  * Place the attribute after the declaration, just before the semicolon.
1979  *
1980  * See the GNU C documentation for more details.
1981  *
1982  * Since: 2.2
1983  */
1984
1985 /**
1986  * G_GNUC_DEPRECATED_FOR:
1987  * @f: the intended replacement for the deprecated symbol,
1988  *     such as the name of a function
1989  *
1990  * Like %G_GNUC_DEPRECATED, but names the intended replacement for the
1991  * deprecated symbol if the version of <command>gcc</command> in use is
1992  * new enough to support custom deprecation messages.
1993  *
1994  * Place the attribute after the declaration, just before the semicolon.
1995  *
1996  * See the GNU C documentation for more details.
1997  *
1998  * Note that if @f is a macro, it will be expanded in the warning message.
1999  * You can enclose it in quotes to prevent this. (The quotes will show up
2000  * in the warning, but it's better than showing the macro expansion.)
2001  *
2002  * Since: 2.26
2003  */
2004
2005 /**
2006  * G_GNUC_BEGIN_IGNORE_DEPRECATIONS:
2007  *
2008  * Tells <command>gcc</command> (if it is a new enough version) to
2009  * temporarily stop emitting warnings when functions marked with
2010  * %G_GNUC_DEPRECATED or %G_GNUC_DEPRECATED_FOR are called. This is
2011  * useful for when you have one deprecated function calling another
2012  * one, or when you still have regression tests for deprecated
2013  * functions.
2014  *
2015  * Use %G_GNUC_END_IGNORE_DEPRECATIONS to begin warning again. (If you
2016  * are not compiling with <literal>-Wdeprecated-declarations</literal>
2017  * then neither macro has any effect.)
2018  *
2019  * This macro can be used either inside or outside of a function body,
2020  * but must appear on a line by itself.
2021  *
2022  * Since: 2.32
2023  */
2024
2025 /**
2026  * G_GNUC_END_IGNORE_DEPRECATIONS:
2027  *
2028  * Undoes the effect of %G_GNUC_BEGIN_IGNORE_DEPRECATIONS, telling
2029  * <command>gcc</command> to begin outputting warnings again
2030  * (assuming those warnings had been enabled to begin with).
2031  *
2032  * This macro can be used either inside or outside of a function body,
2033  * but must appear on a line by itself.
2034  *
2035  * Since: 2.32
2036  */
2037
2038 /**
2039  * G_DEPRECATED:
2040  *
2041  * This macro is similar to %G_GNUC_DEPRECATED, and can be used to mark
2042  * functions declarations as deprecated. Unlike %G_GNUC_DEPRECATED, it is
2043  * meant to be portable across different compilers and must be placed
2044  * before the function declaration.
2045  *
2046  * Since: 2.32
2047  */
2048
2049 /**
2050  * G_DEPRECATED_FOR:
2051  * @f: the name of the function that this function was deprecated for
2052  *
2053  * This macro is similar to %G_GNUC_DEPRECATED_FOR, and can be used to mark
2054  * functions declarations as deprecated. Unlike %G_GNUC_DEPRECATED_FOR, it is
2055  * meant to be portable across different compilers and must be placed
2056  * before the function declaration.
2057  *
2058  * Since: 2.32
2059  */
2060
2061 /**
2062  * G_UNAVAILABLE:
2063  * @maj: the major version that introduced the symbol
2064  * @min: the minor version that introduced the symbol
2065  *
2066  * This macro can be used to mark a function declaration as unavailable.
2067  * It must be placed before the function declaration. Use of a function
2068  * that has been annotated with this macros will produce a compiler warning.
2069  *
2070  * Since: 2.32
2071  */
2072
2073 /**
2074  * GLIB_DISABLE_DEPRECATION_WARNINGS:
2075  *
2076  * A macro that should be defined before including the glib.h header.
2077  * If it is defined, no compiler warnings will be produced for uses
2078  * of deprecated GLib APIs.
2079  */
2080
2081 /**
2082  * G_GNUC_NORETURN:
2083  *
2084  * Expands to the GNU C <literal>noreturn</literal> function attribute
2085  * if the compiler is <command>gcc</command>. It is used for declaring
2086  * functions which never return. It enables optimization of the function,
2087  * and avoids possible compiler warnings.
2088  *
2089  * Place the attribute after the declaration, just before the semicolon.
2090  *
2091  * See the GNU C documentation for more details.
2092  */
2093
2094 /**
2095  * G_GNUC_UNUSED:
2096  *
2097  * Expands to the GNU C <literal>unused</literal> function attribute if
2098  * the compiler is <command>gcc</command>. It is used for declaring
2099  * functions and arguments which may never be used. It avoids possible compiler
2100  * warnings.
2101  *
2102  * For functions, place the attribute after the declaration, just before the
2103  * semicolon. For arguments, place the attribute at the beginning of the
2104  * argument declaration.
2105  *
2106  * |[
2107  * void my_unused_function (G_GNUC_UNUSED gint unused_argument,
2108  *                          gint other_argument) G_GNUC_UNUSED;
2109  * ]|
2110  *
2111  * See the GNU C documentation for more details.
2112  */
2113
2114 /**
2115  * G_GNUC_PRINTF:
2116  * @format_idx: the index of the argument corresponding to the
2117  *     format string (The arguments are numbered from 1)
2118  * @arg_idx: the index of the first of the format arguments
2119  *
2120  * Expands to the GNU C <literal>format</literal> function attribute
2121  * if the compiler is <command>gcc</command>. This is used for declaring
2122  * functions which take a variable number of arguments, with the same
2123  * syntax as printf(). It allows the compiler to type-check the arguments
2124  * passed to the function.
2125  *
2126  * Place the attribute after the function declaration, just before the
2127  * semicolon.
2128  *
2129  * See the GNU C documentation for more details.
2130  *
2131  * |[
2132  * gint g_snprintf (gchar  *string,
2133  *                  gulong       n,
2134  *                  gchar const *format,
2135  *                  ...) G_GNUC_PRINTF (3, 4);
2136  * ]|
2137  */
2138
2139 /**
2140  * G_GNUC_SCANF:
2141  * @format_idx: the index of the argument corresponding to
2142  *     the format string (The arguments are numbered from 1)
2143  * @arg_idx: the index of the first of the format arguments
2144  *
2145  * Expands to the GNU C <literal>format</literal> function attribute
2146  * if the compiler is <command>gcc</command>. This is used for declaring
2147  * functions which take a variable number of arguments, with the same
2148  * syntax as scanf(). It allows the compiler to type-check the arguments
2149  * passed to the function. See the GNU C documentation for details.
2150  */
2151
2152 /**
2153  * G_GNUC_FORMAT:
2154  * @arg_idx: the index of the argument
2155  *
2156  * Expands to the GNU C <literal>format_arg</literal> function attribute
2157  * if the compiler is <command>gcc</command>. This function attribute
2158  * specifies that a function takes a format string for a printf(),
2159  * scanf(), strftime() or strfmon() style function and modifies it,
2160  * so that the result can be passed to a printf(), scanf(), strftime()
2161  * or strfmon() style function (with the remaining arguments to the
2162  * format function the same as they would have been for the unmodified
2163  * string).
2164  *
2165  * Place the attribute after the function declaration, just before the
2166  * semicolon.
2167  *
2168  * See the GNU C documentation for more details.
2169  *
2170  * |[
2171  * gchar *g_dgettext (gchar *domain_name, gchar *msgid) G_GNUC_FORMAT (2);
2172  * ]|
2173  */
2174
2175 /**
2176  * G_GNUC_NULL_TERMINATED:
2177  *
2178  * Expands to the GNU C <literal>sentinel</literal> function attribute
2179  * if the compiler is <command>gcc</command>, or "" if it isn't. This
2180  * function attribute only applies to variadic functions and instructs
2181  * the compiler to check that the argument list is terminated with an
2182  * explicit %NULL.
2183  *
2184  * Place the attribute after the declaration, just before the semicolon.
2185  *
2186  * See the GNU C documentation for more details.
2187  *
2188  * Since: 2.8
2189  */
2190
2191 /**
2192  * G_GNUC_WARN_UNUSED_RESULT:
2193  *
2194  * Expands to the GNU C <literal>warn_unused_result</literal> function
2195  * attribute if the compiler is <command>gcc</command>, or "" if it isn't.
2196  * This function attribute makes the compiler emit a warning if the result
2197  * of a function call is ignored.
2198  *
2199  * Place the attribute after the declaration, just before the semicolon.
2200  *
2201  * See the GNU C documentation for more details.
2202  *
2203  * Since: 2.10
2204  */
2205
2206 /**
2207  * G_GNUC_FUNCTION:
2208  *
2209  * Expands to "" on all modern compilers, and to
2210  * <literal>__FUNCTION__</literal> on <command>gcc</command> version 2.x.
2211  * Don't use it.
2212  *
2213  * Deprecated: 2.16: Use #G_STRFUNC instead
2214  */
2215
2216 /**
2217  * G_GNUC_PRETTY_FUNCTION:
2218  *
2219  * Expands to "" on all modern compilers, and to
2220  * <literal>__PRETTY_FUNCTION__</literal> on <command>gcc</command>
2221  * version 2.x. Don't use it.
2222  *
2223  * Deprecated: 2.16: Use #G_STRFUNC instead
2224  */
2225
2226 /**
2227  * G_GNUC_NO_INSTRUMENT:
2228  *
2229  * Expands to the GNU C <literal>no_instrument_function</literal> function
2230  * attribute if the compiler is <command>gcc</command>. Functions with this
2231  * attribute will not be instrumented for profiling, when the compiler is
2232  * called with the <option>-finstrument-functions</option> option.
2233  *
2234  * Place the attribute after the declaration, just before the semicolon.
2235  *
2236  * See the GNU C documentation for more details.
2237  */
2238
2239 /**
2240  * G_GNUC_INTERNAL:
2241  *
2242  * This attribute can be used for marking library functions as being used
2243  * internally to the library only, which may allow the compiler to handle
2244  * function calls more efficiently. Note that static functions do not need
2245  * to be marked as internal in this way. See the GNU C documentation for
2246  * details.
2247  *
2248  * When using a compiler that supports the GNU C hidden visibility attribute,
2249  * this macro expands to <literal>__attribute__((visibility("hidden")))</literal>.
2250  * When using the Sun Studio compiler, it expands to <literal>__hidden</literal>.
2251  *
2252  * Note that for portability, the attribute should be placed before the
2253  * function declaration. While GCC allows the macro after the declaration,
2254  * Sun Studio does not.
2255  *
2256  * |[
2257  * G_GNUC_INTERNAL
2258  * void _g_log_fallback_handler (const gchar    *log_domain,
2259  *                               GLogLevelFlags  log_level,
2260  *                               const gchar    *message,
2261  *                               gpointer        unused_data);
2262  * ]|
2263  *
2264  * Since: 2.6
2265  */
2266
2267 /**
2268  * G_GNUC_MAY_ALIAS:
2269  *
2270  * Expands to the GNU C <literal>may_alias</literal> type attribute
2271  * if the compiler is <command>gcc</command>. Types with this attribute
2272  * will not be subjected to type-based alias analysis, but are assumed
2273  * to alias with any other type, just like char.
2274  * See the GNU C documentation for details.
2275  *
2276  * Since: 2.14
2277  */
2278
2279 /**
2280  * G_LIKELY:
2281  * @expr: the expression
2282  *
2283  * Hints the compiler that the expression is likely to evaluate to
2284  * a true value. The compiler may use this information for optimizations.
2285  *
2286  * |[
2287  * if (G_LIKELY (random () != 1))
2288  *   g_print ("not one");
2289  * ]|
2290  *
2291  * Returns: the value of @expr
2292  *
2293  * Since: 2.2
2294  */
2295
2296 /**
2297  * G_UNLIKELY:
2298  * @expr: the expression
2299  *
2300  * Hints the compiler that the expression is unlikely to evaluate to
2301  * a true value. The compiler may use this information for optimizations.
2302  *
2303  * |[
2304  * if (G_UNLIKELY (random () == 1))
2305  *   g_print ("a random one");
2306  * ]|
2307  *
2308  * Returns: the value of @expr
2309  *
2310  * Since: 2.2
2311  */
2312
2313 /**
2314  * G_STRLOC:
2315  *
2316  * Expands to a string identifying the current code position.
2317  */
2318
2319 /**
2320  * G_STRFUNC:
2321  *
2322  * Expands to a string identifying the current function.
2323  *
2324  * Since: 2.4
2325  */
2326
2327 /* Windows Compatibility Functions {{{1 */
2328
2329 /**
2330  * SECTION:windows
2331  * @title: Windows Compatibility Functions
2332  * @short_description: UNIX emulation on Windows
2333  *
2334  * These functions provide some level of UNIX emulation on the
2335  * Windows platform. If your application really needs the POSIX
2336  * APIs, we suggest you try the Cygwin project.
2337  */
2338
2339 /**
2340  * MAXPATHLEN:
2341  *
2342  * Provided for UNIX emulation on Windows; equivalent to UNIX
2343  * macro %MAXPATHLEN, which is the maximum length of a filename
2344  * (including full path).
2345  */
2346
2347 /**
2348  * G_WIN32_DLLMAIN_FOR_DLL_NAME:
2349  * @static: empty or "static"
2350  * @dll_name: the name of the (pointer to the) char array where
2351  *     the DLL name will be stored. If this is used, you must also
2352  *     include <filename>windows.h</filename>. If you need a more
2353  *     complex DLL entry point function, you cannot use this
2354  *
2355  * On Windows, this macro defines a DllMain() function that stores
2356  * the actual DLL name that the code being compiled will be included in.
2357  *
2358  * On non-Windows platforms, expands to nothing.
2359  */
2360
2361 /**
2362  * G_WIN32_HAVE_WIDECHAR_API:
2363  *
2364  * On Windows, this macro defines an expression which evaluates to
2365  * %TRUE if the code is running on a version of Windows where the wide
2366  * character versions of the Win32 API functions, and the wide character
2367  * versions of the C library functions work. (They are always present in
2368  * the DLLs, but don't work on Windows 9x and Me.)
2369  *
2370  * On non-Windows platforms, it is not defined.
2371  *
2372  * Since: 2.6
2373  */
2374
2375
2376 /**
2377  * G_WIN32_IS_NT_BASED:
2378  *
2379  * On Windows, this macro defines an expression which evaluates to
2380  * %TRUE if the code is running on an NT-based Windows operating system.
2381  *
2382  * On non-Windows platforms, it is not defined.
2383  *
2384  * Since: 2.6
2385  */
2386
2387 /* Epilogue {{{1 */
2388 /* vim: set foldmethod=marker: */