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