Updated Hungarian translation
[glib.git] / glib / docs.c
blob9169d85ea4eedd087d8a6f266c364e00399bf5cf
1 /*
2 * Copyright © 2011 Red Hat, Inc
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.
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.
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/>.
17 * Author: Matthias Clasen
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.
26 /* Basic types {{{1 */
28 /**
29 * SECTION:types
30 * @title: Basic Types
31 * @short_description: standard GLib types, defined for ease-of-use
32 * and portability
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.
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.
53 /**
54 * gboolean:
56 * A standard boolean type.
57 * Variables of this type should only contain the value
58 * %TRUE or %FALSE.
61 /**
62 * gpointer:
64 * An untyped pointer.
65 * #gpointer looks better and is easier to use than void*.
68 /**
69 * gconstpointer:
71 * An untyped pointer to constant data.
72 * The data pointed to should not be changed.
74 * This is typically used in function prototypes to indicate
75 * that the data pointed to will not be altered by the function.
78 /**
79 * gchar:
81 * Corresponds to the standard C char type.
84 /**
85 * guchar:
87 * Corresponds to the standard C unsigned char type.
90 /**
91 * gint:
93 * Corresponds to the standard C int type.
94 * Values of this type can range from #G_MININT to #G_MAXINT.
97 /**
98 * G_MININT:
100 * The minimum value which can be held in a #gint.
104 * G_MAXINT:
106 * The maximum value which can be held in a #gint.
110 * guint:
112 * Corresponds to the standard C unsigned int type.
113 * Values of this type can range from 0 to #G_MAXUINT.
117 * G_MAXUINT:
119 * The maximum value which can be held in a #guint.
123 * gshort:
125 * Corresponds to the standard C short type.
126 * Values of this type can range from #G_MINSHORT to #G_MAXSHORT.
130 * G_MINSHORT:
132 * The minimum value which can be held in a #gshort.
136 * G_MAXSHORT:
138 * The maximum value which can be held in a #gshort.
142 * gushort:
144 * Corresponds to the standard C unsigned short type.
145 * Values of this type can range from 0 to #G_MAXUSHORT.
149 * G_MAXUSHORT:
151 * The maximum value which can be held in a #gushort.
155 * glong:
157 * Corresponds to the standard C long type.
158 * Values of this type can range from #G_MINLONG to #G_MAXLONG.
162 * G_MINLONG:
164 * The minimum value which can be held in a #glong.
168 * G_MAXLONG:
170 * The maximum value which can be held in a #glong.
174 * gulong:
176 * Corresponds to the standard C unsigned long type.
177 * Values of this type can range from 0 to #G_MAXULONG.
181 * G_MAXULONG:
183 * The maximum value which can be held in a #gulong.
187 * gint8:
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).
195 * G_MININT8:
197 * The minimum value which can be held in a #gint8.
199 * Since: 2.4
203 * G_MAXINT8:
205 * The maximum value which can be held in a #gint8.
207 * Since: 2.4
211 * guint8:
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).
218 * G_MAXUINT8:
220 * The maximum value which can be held in a #guint8.
222 * Since: 2.4
226 * gint16:
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).
232 * To print or scan values of this type, use
233 * %G_GINT16_MODIFIER and/or %G_GINT16_FORMAT.
237 * G_MININT16:
239 * The minimum value which can be held in a #gint16.
241 * Since: 2.4
245 * G_MAXINT16:
247 * The maximum value which can be held in a #gint16.
249 * Since: 2.4
253 * G_GINT16_MODIFIER:
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.
261 * The following example prints "0x7b";
262 * |[<!-- language="C" -->
263 * gint16 value = 123;
264 * g_print ("%#" G_GINT16_MODIFIER "x", value);
265 * ]|
267 * Since: 2.4
271 * G_GINT16_FORMAT:
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.
278 * |[<!-- language="C" -->
279 * gint16 in;
280 * gint32 out;
281 * sscanf ("42", "%" G_GINT16_FORMAT, &in)
282 * out = in * 1000;
283 * g_print ("%" G_GINT32_FORMAT, out);
284 * ]|
288 * guint16:
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).
293 * To print or scan values of this type, use
294 * %G_GINT16_MODIFIER and/or %G_GUINT16_FORMAT.
298 * G_MAXUINT16:
300 * The maximum value which can be held in a #guint16.
302 * Since: 2.4
306 * G_GUINT16_FORMAT:
308 * This is the platform dependent conversion specifier for scanning
309 * and printing values of type #guint16. See also #G_GINT16_FORMAT
313 * gint32:
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).
319 * To print or scan values of this type, use
320 * %G_GINT32_MODIFIER and/or %G_GINT32_FORMAT.
324 * G_MININT32:
326 * The minimum value which can be held in a #gint32.
328 * Since: 2.4
332 * G_MAXINT32:
334 * The maximum value which can be held in a #gint32.
336 * Since: 2.4
340 * G_GINT32_MODIFIER:
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.
346 * Since: 2.4
350 * G_GINT32_FORMAT:
352 * This is the platform dependent conversion specifier for scanning
353 * and printing values of type #gint32. See also #G_GINT16_FORMAT.
357 * guint32:
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).
362 * To print or scan values of this type, use
363 * %G_GINT32_MODIFIER and/or %G_GUINT32_FORMAT.
367 * G_MAXUINT32:
369 * The maximum value which can be held in a #guint32.
371 * Since: 2.4
375 * G_GUINT32_FORMAT:
377 * This is the platform dependent conversion specifier for scanning
378 * and printing values of type #guint32. See also #G_GINT16_FORMAT.
382 * gint64:
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).
389 * To print or scan values of this type, use
390 * %G_GINT64_MODIFIER and/or %G_GINT64_FORMAT.
394 * G_MININT64:
396 * The minimum value which can be held in a #gint64.
400 * G_MAXINT64:
402 * The maximum value which can be held in a #gint64.
406 * G_GINT64_MODIFIER:
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.
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.
416 * Since: 2.4
420 * G_GINT64_FORMAT:
422 * This is the platform dependent conversion specifier for scanning
423 * and printing values of type #gint64. See also #G_GINT16_FORMAT.
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.
434 * guint64:
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).
440 * To print or scan values of this type, use
441 * %G_GINT64_MODIFIER and/or %G_GUINT64_FORMAT.
445 * G_MAXUINT64:
447 * The maximum value which can be held in a #guint64.
451 * G_GUINT64_FORMAT:
453 * This is the platform dependent conversion specifier for scanning
454 * and printing values of type #guint64. See also #G_GINT16_FORMAT.
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.
465 * G_GINT64_CONSTANT:
466 * @val: a literal integer value, e.g. 0x1d636b02300a7aa7
468 * This macro is used to insert 64-bit integer literals
469 * into the source code.
473 * G_GUINT64_CONSTANT:
474 * @val: a literal integer value, e.g. 0x1d636b02300a7aa7U
476 * This macro is used to insert 64-bit unsigned integer
477 * literals into the source code.
479 * Since: 2.10
483 * gfloat:
485 * Corresponds to the standard C float type.
486 * Values of this type can range from -#G_MAXFLOAT to #G_MAXFLOAT.
490 * G_MINFLOAT:
492 * The minimum positive value which can be held in a #gfloat.
494 * If you are interested in the smallest value which can be held
495 * in a #gfloat, use -%G_MAXFLOAT.
499 * G_MAXFLOAT:
501 * The maximum value which can be held in a #gfloat.
505 * gdouble:
507 * Corresponds to the standard C double type.
508 * Values of this type can range from -#G_MAXDOUBLE to #G_MAXDOUBLE.
512 * G_MINDOUBLE:
514 * The minimum positive value which can be held in a #gdouble.
516 * If you are interested in the smallest value which can be held
517 * in a #gdouble, use -%G_MAXDOUBLE.
521 * G_MAXDOUBLE:
523 * The maximum value which can be held in a #gdouble.
527 * gsize:
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.
536 * To print or scan values of this type, use
537 * %G_GSIZE_MODIFIER and/or %G_GSIZE_FORMAT.
541 * G_MAXSIZE:
543 * The maximum value which can be held in a #gsize.
545 * Since: 2.4
549 * G_GSIZE_MODIFIER:
551 * The platform dependent length modifier for conversion specifiers
552 * for scanning and printing values of type #gsize. It
553 * is a string literal.
555 * Since: 2.6
559 * G_GSIZE_FORMAT:
561 * This is the platform dependent conversion specifier for scanning
562 * and printing values of type #gsize. See also #G_GINT16_FORMAT.
564 * Since: 2.6
568 * gssize:
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.
575 * To print or scan values of this type, use
576 * %G_GSSIZE_MODIFIER and/or %G_GSSIZE_FORMAT.
580 * G_MINSSIZE:
582 * The minimum value which can be held in a #gssize.
584 * Since: 2.14
588 * G_MAXSSIZE:
590 * The maximum value which can be held in a #gssize.
592 * Since: 2.14
596 * G_GSSIZE_FORMAT:
598 * This is the platform dependent conversion specifier for scanning
599 * and printing values of type #gssize. See also #G_GINT16_FORMAT.
601 * Since: 2.6
605 * G_GSSIZE_MODIFIER:
607 * The platform dependent length modifier for conversion specifiers
608 * for scanning and printing values of type #gssize. It
609 * is a string literal.
611 * Since: 2.6
615 * goffset:
617 * A signed integer type that is used for file offsets,
618 * corresponding to the C99 type off64_t.
619 * Values of this type can range from #G_MINOFFSET to
620 * #G_MAXOFFSET.
622 * To print or scan values of this type, use
623 * %G_GOFFSET_MODIFIER and/or %G_GOFFSET_FORMAT.
625 * Since: 2.14
629 * G_MINOFFSET:
631 * The minimum value which can be held in a #goffset.
635 * G_MAXOFFSET:
637 * The maximum value which can be held in a #goffset.
641 * G_GOFFSET_MODIFIER:
643 * The platform dependent length modifier for conversion specifiers
644 * for scanning and printing values of type #goffset. It is a string
645 * literal. See also #G_GINT64_MODIFIER.
647 * Since: 2.20
651 * G_GOFFSET_FORMAT:
653 * This is the platform dependent conversion specifier for scanning
654 * and printing values of type #goffset. See also #G_GINT64_FORMAT.
656 * Since: 2.20
660 * G_GOFFSET_CONSTANT:
661 * @val: a literal integer value, e.g. 0x1d636b02300a7aa7
663 * This macro is used to insert #goffset 64-bit integer literals
664 * into the source code.
666 * See also #G_GINT64_CONSTANT.
668 * Since: 2.20
672 * gintptr:
674 * Corresponds to the C99 type intptr_t,
675 * a signed integer type that can hold any pointer.
677 * To print or scan values of this type, use
678 * %G_GINTPTR_MODIFIER and/or %G_GINTPTR_FORMAT.
680 * Since: 2.18
684 * G_GINTPTR_MODIFIER:
686 * The platform dependent length modifier for conversion specifiers
687 * for scanning and printing values of type #gintptr or #guintptr.
688 * It is a string literal.
690 * Since: 2.22
694 * G_GINTPTR_FORMAT:
696 * This is the platform dependent conversion specifier for scanning
697 * and printing values of type #gintptr.
699 * Since: 2.22
703 * guintptr:
705 * Corresponds to the C99 type uintptr_t,
706 * an unsigned integer type that can hold any pointer.
708 * To print or scan values of this type, use
709 * %G_GINTPTR_MODIFIER and/or %G_GUINTPTR_FORMAT.
711 * Since: 2.18
715 * G_GUINTPTR_FORMAT:
717 * This is the platform dependent conversion specifier
718 * for scanning and printing values of type #guintptr.
720 * Since: 2.22
723 /* Type conversion {{{1 */
726 * SECTION:type_conversion
727 * @title: Type Conversion Macros
728 * @short_description: portably storing integers in pointer variables
730 * Many times GLib, GTK+, and other libraries allow you to pass "user
731 * data" to a callback, in the form of a void pointer. From time to time
732 * you want to pass an integer instead of a pointer. You could allocate
733 * an integer, with something like:
734 * |[<!-- language="C" -->
735 * int *ip = g_new (int, 1);
736 * *ip = 42;
737 * ]|
738 * But this is inconvenient, and it's annoying to have to free the
739 * memory at some later time.
741 * Pointers are always at least 32 bits in size (on all platforms GLib
742 * intends to support). Thus you can store at least 32-bit integer values
743 * in a pointer value. Naively, you might try this, but it's incorrect:
744 * |[<!-- language="C" -->
745 * gpointer p;
746 * int i;
747 * p = (void*) 42;
748 * i = (int) p;
749 * ]|
750 * Again, that example was not correct, don't copy it.
751 * The problem is that on some systems you need to do this:
752 * |[<!-- language="C" -->
753 * gpointer p;
754 * int i;
755 * p = (void*) (long) 42;
756 * i = (int) (long) p;
757 * ]|
758 * The GLib macros GPOINTER_TO_INT(), GINT_TO_POINTER(), etc. take care
759 * to do the right thing on the every platform.
761 * Warning: You may not store pointers in integers. This is not
762 * portable in any way, shape or form. These macros only allow storing
763 * integers in pointers, and only preserve 32 bits of the integer; values
764 * outside the range of a 32-bit integer will be mangled.
768 * GINT_TO_POINTER:
769 * @i: integer to stuff into a pointer
771 * Stuffs an integer into a pointer type.
773 * Remember, you may not store pointers in integers. This is not portable
774 * in any way, shape or form. These macros only allow storing integers in
775 * pointers, and only preserve 32 bits of the integer; values outside the
776 * range of a 32-bit integer will be mangled.
780 * GPOINTER_TO_INT:
781 * @p: pointer containing an integer
783 * Extracts an integer from a pointer. The integer must have
784 * been stored in the pointer with GINT_TO_POINTER().
786 * Remember, you may not store pointers in integers. This is not portable
787 * in any way, shape or form. These macros only allow storing integers in
788 * pointers, and only preserve 32 bits of the integer; values outside the
789 * range of a 32-bit integer will be mangled.
793 * GUINT_TO_POINTER:
794 * @u: unsigned integer to stuff into the pointer
796 * Stuffs an unsigned integer into a pointer type.
800 * GPOINTER_TO_UINT:
801 * @p: pointer to extract an unsigned integer from
803 * Extracts an unsigned integer from a pointer. The integer must have
804 * been stored in the pointer with GUINT_TO_POINTER().
808 * GSIZE_TO_POINTER:
809 * @s: #gsize to stuff into the pointer
811 * Stuffs a #gsize into a pointer type.
815 * GPOINTER_TO_SIZE:
816 * @p: pointer to extract a #gsize from
818 * Extracts a #gsize from a pointer. The #gsize must have
819 * been stored in the pointer with GSIZE_TO_POINTER().
822 /* Byte order {{{1 */
825 * SECTION:byte_order
826 * @title: Byte Order Macros
827 * @short_description: a portable way to convert between different byte orders
829 * These macros provide a portable way to determine the host byte order
830 * and to convert values between different byte orders.
832 * The byte order is the order in which bytes are stored to create larger
833 * data types such as the #gint and #glong values.
834 * The host byte order is the byte order used on the current machine.
836 * Some processors store the most significant bytes (i.e. the bytes that
837 * hold the largest part of the value) first. These are known as big-endian
838 * processors. Other processors (notably the x86 family) store the most
839 * significant byte last. These are known as little-endian processors.
841 * Finally, to complicate matters, some other processors store the bytes in
842 * a rather curious order known as PDP-endian. For a 4-byte word, the 3rd
843 * most significant byte is stored first, then the 4th, then the 1st and
844 * finally the 2nd.
846 * Obviously there is a problem when these different processors communicate
847 * with each other, for example over networks or by using binary file formats.
848 * This is where these macros come in. They are typically used to convert
849 * values into a byte order which has been agreed on for use when
850 * communicating between different processors. The Internet uses what is
851 * known as 'network byte order' as the standard byte order (which is in
852 * fact the big-endian byte order).
854 * Note that the byte order conversion macros may evaluate their arguments
855 * multiple times, thus you should not use them with arguments which have
856 * side-effects.
860 * G_BYTE_ORDER:
862 * The host byte order.
863 * This can be either #G_LITTLE_ENDIAN or #G_BIG_ENDIAN (support for
864 * #G_PDP_ENDIAN may be added in future.)
868 * G_LITTLE_ENDIAN:
870 * Specifies one of the possible types of byte order.
871 * See #G_BYTE_ORDER.
875 * G_BIG_ENDIAN:
877 * Specifies one of the possible types of byte order.
878 * See #G_BYTE_ORDER.
882 * G_PDP_ENDIAN:
884 * Specifies one of the possible types of byte order
885 * (currently unused). See #G_BYTE_ORDER.
889 * g_htonl:
890 * @val: a 32-bit integer value in host byte order
892 * Converts a 32-bit integer value from host to network byte order.
894 * Returns: @val converted to network byte order
898 * g_htons:
899 * @val: a 16-bit integer value in host byte order
901 * Converts a 16-bit integer value from host to network byte order.
903 * Returns: @val converted to network byte order
907 * g_ntohl:
908 * @val: a 32-bit integer value in network byte order
910 * Converts a 32-bit integer value from network to host byte order.
912 * Returns: @val converted to host byte order.
916 * g_ntohs:
917 * @val: a 16-bit integer value in network byte order
919 * Converts a 16-bit integer value from network to host byte order.
921 * Returns: @val converted to host byte order
925 * GINT_FROM_BE:
926 * @val: a #gint value in big-endian byte order
928 * Converts a #gint value from big-endian to host byte order.
930 * Returns: @val converted to host byte order
934 * GINT_FROM_LE:
935 * @val: a #gint value in little-endian byte order
937 * Converts a #gint value from little-endian to host byte order.
939 * Returns: @val converted to host byte order
943 * GINT_TO_BE:
944 * @val: a #gint value in host byte order
946 * Converts a #gint value from host byte order to big-endian.
948 * Returns: @val converted to big-endian byte order
952 * GINT_TO_LE:
953 * @val: a #gint value in host byte order
955 * Converts a #gint value from host byte order to little-endian.
957 * Returns: @val converted to little-endian byte order
961 * GUINT_FROM_BE:
962 * @val: a #guint value in big-endian byte order
964 * Converts a #guint value from big-endian to host byte order.
966 * Returns: @val converted to host byte order
970 * GUINT_FROM_LE:
971 * @val: a #guint value in little-endian byte order
973 * Converts a #guint value from little-endian to host byte order.
975 * Returns: @val converted to host byte order
979 * GUINT_TO_BE:
980 * @val: a #guint value in host byte order
982 * Converts a #guint value from host byte order to big-endian.
984 * Returns: @val converted to big-endian byte order
988 * GUINT_TO_LE:
989 * @val: a #guint value in host byte order
991 * Converts a #guint value from host byte order to little-endian.
993 * Returns: @val converted to little-endian byte order.
997 * GLONG_FROM_BE:
998 * @val: a #glong value in big-endian byte order
1000 * Converts a #glong value from big-endian to the host byte order.
1002 * Returns: @val converted to host byte order
1006 * GLONG_FROM_LE:
1007 * @val: a #glong value in little-endian byte order
1009 * Converts a #glong value from little-endian to host byte order.
1011 * Returns: @val converted to host byte order
1015 * GLONG_TO_BE:
1016 * @val: a #glong value in host byte order
1018 * Converts a #glong value from host byte order to big-endian.
1020 * Returns: @val converted to big-endian byte order
1024 * GLONG_TO_LE:
1025 * @val: a #glong value in host byte order
1027 * Converts a #glong value from host byte order to little-endian.
1029 * Returns: @val converted to little-endian
1033 * GULONG_FROM_BE:
1034 * @val: a #gulong value in big-endian byte order
1036 * Converts a #gulong value from big-endian to host byte order.
1038 * Returns: @val converted to host byte order
1042 * GULONG_FROM_LE:
1043 * @val: a #gulong value in little-endian byte order
1045 * Converts a #gulong value from little-endian to host byte order.
1047 * Returns: @val converted to host byte order
1051 * GULONG_TO_BE:
1052 * @val: a #gulong value in host byte order
1054 * Converts a #gulong value from host byte order to big-endian.
1056 * Returns: @val converted to big-endian
1060 * GULONG_TO_LE:
1061 * @val: a #gulong value in host byte order
1063 * Converts a #gulong value from host byte order to little-endian.
1065 * Returns: @val converted to little-endian
1069 * GSIZE_FROM_BE:
1070 * @val: a #gsize value in big-endian byte order
1072 * Converts a #gsize value from big-endian to the host byte order.
1074 * Returns: @val converted to host byte order
1078 * GSIZE_FROM_LE:
1079 * @val: a #gsize value in little-endian byte order
1081 * Converts a #gsize value from little-endian to host byte order.
1083 * Returns: @val converted to host byte order
1087 * GSIZE_TO_BE:
1088 * @val: a #gsize value in host byte order
1090 * Converts a #gsize value from host byte order to big-endian.
1092 * Returns: @val converted to big-endian byte order
1096 * GSIZE_TO_LE:
1097 * @val: a #gsize value in host byte order
1099 * Converts a #gsize value from host byte order to little-endian.
1101 * Returns: @val converted to little-endian
1105 * GSSIZE_FROM_BE:
1106 * @val: a #gssize value in big-endian byte order
1108 * Converts a #gssize value from big-endian to host byte order.
1110 * Returns: @val converted to host byte order
1114 * GSSIZE_FROM_LE:
1115 * @val: a #gssize value in little-endian byte order
1117 * Converts a #gssize value from little-endian to host byte order.
1119 * Returns: @val converted to host byte order
1123 * GSSIZE_TO_BE:
1124 * @val: a #gssize value in host byte order
1126 * Converts a #gssize value from host byte order to big-endian.
1128 * Returns: @val converted to big-endian
1132 * GSSIZE_TO_LE:
1133 * @val: a #gssize value in host byte order
1135 * Converts a #gssize value from host byte order to little-endian.
1137 * Returns: @val converted to little-endian
1141 * GINT16_FROM_BE:
1142 * @val: a #gint16 value in big-endian byte order
1144 * Converts a #gint16 value from big-endian to host byte order.
1146 * Returns: @val converted to host byte order
1150 * GINT16_FROM_LE:
1151 * @val: a #gint16 value in little-endian byte order
1153 * Converts a #gint16 value from little-endian to host byte order.
1155 * Returns: @val converted to host byte order
1159 * GINT16_TO_BE:
1160 * @val: a #gint16 value in host byte order
1162 * Converts a #gint16 value from host byte order to big-endian.
1164 * Returns: @val converted to big-endian
1168 * GINT16_TO_LE:
1169 * @val: a #gint16 value in host byte order
1171 * Converts a #gint16 value from host byte order to little-endian.
1173 * Returns: @val converted to little-endian
1177 * GUINT16_FROM_BE:
1178 * @val: a #guint16 value in big-endian byte order
1180 * Converts a #guint16 value from big-endian to host byte order.
1182 * Returns: @val converted to host byte order
1186 * GUINT16_FROM_LE:
1187 * @val: a #guint16 value in little-endian byte order
1189 * Converts a #guint16 value from little-endian to host byte order.
1191 * Returns: @val converted to host byte order
1195 * GUINT16_TO_BE:
1196 * @val: a #guint16 value in host byte order
1198 * Converts a #guint16 value from host byte order to big-endian.
1200 * Returns: @val converted to big-endian
1204 * GUINT16_TO_LE:
1205 * @val: a #guint16 value in host byte order
1207 * Converts a #guint16 value from host byte order to little-endian.
1209 * Returns: @val converted to little-endian
1213 * GINT32_FROM_BE:
1214 * @val: a #gint32 value in big-endian byte order
1216 * Converts a #gint32 value from big-endian to host byte order.
1218 * Returns: @val converted to host byte order
1222 * GINT32_FROM_LE:
1223 * @val: a #gint32 value in little-endian byte order
1225 * Converts a #gint32 value from little-endian to host byte order.
1227 * Returns: @val converted to host byte order
1231 * GINT32_TO_BE:
1232 * @val: a #gint32 value in host byte order
1234 * Converts a #gint32 value from host byte order to big-endian.
1236 * Returns: @val converted to big-endian
1240 * GINT32_TO_LE:
1241 * @val: a #gint32 value in host byte order
1243 * Converts a #gint32 value from host byte order to little-endian.
1245 * Returns: @val converted to little-endian
1249 * GUINT32_FROM_BE:
1250 * @val: a #guint32 value in big-endian byte order
1252 * Converts a #guint32 value from big-endian to host byte order.
1254 * Returns: @val converted to host byte order
1258 * GUINT32_FROM_LE:
1259 * @val: a #guint32 value in little-endian byte order
1261 * Converts a #guint32 value from little-endian to host byte order.
1263 * Returns: @val converted to host byte order
1267 * GUINT32_TO_BE:
1268 * @val: a #guint32 value in host byte order
1270 * Converts a #guint32 value from host byte order to big-endian.
1272 * Returns: @val converted to big-endian
1276 * GUINT32_TO_LE:
1277 * @val: a #guint32 value in host byte order
1279 * Converts a #guint32 value from host byte order to little-endian.
1281 * Returns: @val converted to little-endian
1285 * GINT64_FROM_BE:
1286 * @val: a #gint64 value in big-endian byte order
1288 * Converts a #gint64 value from big-endian to host byte order.
1290 * Returns: @val converted to host byte order
1294 * GINT64_FROM_LE:
1295 * @val: a #gint64 value in little-endian byte order
1297 * Converts a #gint64 value from little-endian to host byte order.
1299 * Returns: @val converted to host byte order
1303 * GINT64_TO_BE:
1304 * @val: a #gint64 value in host byte order
1306 * Converts a #gint64 value from host byte order to big-endian.
1308 * Returns: @val converted to big-endian
1312 * GINT64_TO_LE:
1313 * @val: a #gint64 value in host byte order
1315 * Converts a #gint64 value from host byte order to little-endian.
1317 * Returns: @val converted to little-endian
1321 * GUINT64_FROM_BE:
1322 * @val: a #guint64 value in big-endian byte order
1324 * Converts a #guint64 value from big-endian to host byte order.
1326 * Returns: @val converted to host byte order
1330 * GUINT64_FROM_LE:
1331 * @val: a #guint64 value in little-endian byte order
1333 * Converts a #guint64 value from little-endian to host byte order.
1335 * Returns: @val converted to host byte order
1339 * GUINT64_TO_BE:
1340 * @val: a #guint64 value in host byte order
1342 * Converts a #guint64 value from host byte order to big-endian.
1344 * Returns: @val converted to big-endian
1348 * GUINT64_TO_LE:
1349 * @val: a #guint64 value in host byte order
1351 * Converts a #guint64 value from host byte order to little-endian.
1353 * Returns: @val converted to little-endian
1357 * GUINT16_SWAP_BE_PDP:
1358 * @val: a #guint16 value in big-endian or pdp-endian byte order
1360 * Converts a #guint16 value between big-endian and pdp-endian byte order.
1361 * The conversion is symmetric so it can be used both ways.
1363 * Returns: @val converted to the opposite byte order
1367 * GUINT16_SWAP_LE_BE:
1368 * @val: a #guint16 value in little-endian or big-endian byte order
1370 * Converts a #guint16 value between little-endian and big-endian byte order.
1371 * The conversion is symmetric so it can be used both ways.
1373 * Returns: @val converted to the opposite byte order
1377 * GUINT16_SWAP_LE_PDP:
1378 * @val: a #guint16 value in little-endian or pdp-endian byte order
1380 * Converts a #guint16 value between little-endian and pdp-endian byte order.
1381 * The conversion is symmetric so it can be used both ways.
1383 * Returns: @val converted to the opposite byte order
1387 * GUINT32_SWAP_BE_PDP:
1388 * @val: a #guint32 value in big-endian or pdp-endian byte order
1390 * Converts a #guint32 value between big-endian and pdp-endian byte order.
1391 * The conversion is symmetric so it can be used both ways.
1393 * Returns: @val converted to the opposite byte order
1397 * GUINT32_SWAP_LE_BE:
1398 * @val: a #guint32 value in little-endian or big-endian byte order
1400 * Converts a #guint32 value between little-endian and big-endian byte order.
1401 * The conversion is symmetric so it can be used both ways.
1403 * Returns: @val converted to the opposite byte order
1407 * GUINT32_SWAP_LE_PDP:
1408 * @val: a #guint32 value in little-endian or pdp-endian byte order
1410 * Converts a #guint32 value between little-endian and pdp-endian byte order.
1411 * The conversion is symmetric so it can be used both ways.
1413 * Returns: @val converted to the opposite byte order
1417 * GUINT64_SWAP_LE_BE:
1418 * @val: a #guint64 value in little-endian or big-endian byte order
1420 * Converts a #guint64 value between little-endian and big-endian byte order.
1421 * The conversion is symmetric so it can be used both ways.
1423 * Returns: @val converted to the opposite byte order
1426 /* Numerical Definitions {{{1 */
1429 * SECTION:numerical
1430 * @title: Numerical Definitions
1431 * @short_description: mathematical constants, and floating point decomposition
1433 * GLib offers mathematical constants such as #G_PI for the value of pi;
1434 * many platforms have these in the C library, but some don't, the GLib
1435 * versions always exist.
1437 * The #GFloatIEEE754 and #GDoubleIEEE754 unions are used to access the
1438 * sign, mantissa and exponent of IEEE floats and doubles. These unions are
1439 * defined as appropriate for a given platform. IEEE floats and doubles are
1440 * supported (used for storage) by at least Intel, PPC and Sparc. See
1441 * [IEEE 754-2008](http://en.wikipedia.org/wiki/IEEE_float)
1442 * for more information about IEEE number formats.
1446 * G_IEEE754_FLOAT_BIAS:
1448 * The bias by which exponents in single-precision floats are offset.
1452 * G_IEEE754_DOUBLE_BIAS:
1454 * The bias by which exponents in double-precision floats are offset.
1458 * GFloatIEEE754:
1459 * @v_float: the double value
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.
1468 * GDoubleIEEE754:
1469 * @v_double: the double value
1471 * The #GFloatIEEE754 and #GDoubleIEEE754 unions are used to access the sign,
1472 * mantissa and exponent of IEEE floats and doubles. These unions are defined
1473 * as appropriate for a given platform. IEEE floats and doubles are supported
1474 * (used for storage) by at least Intel, PPC and Sparc.
1478 * G_E:
1480 * The base of natural logarithms.
1484 * G_LN2:
1486 * The natural logarithm of 2.
1490 * G_LN10:
1492 * The natural logarithm of 10.
1496 * G_PI:
1498 * The value of pi (ratio of circle's circumference to its diameter).
1502 * G_PI_2:
1504 * Pi divided by 2.
1508 * G_PI_4:
1510 * Pi divided by 4.
1514 * G_SQRT2:
1516 * The square root of two.
1520 * G_LOG_2_BASE_10:
1522 * Multiplying the base 2 exponent by this number yields the base 10 exponent.
1525 /* Macros {{{1 */
1528 * SECTION:macros
1529 * @title: Standard Macros
1530 * @short_description: commonly-used macros
1532 * These macros provide a few commonly-used features.
1536 * G_OS_WIN32:
1538 * This macro is defined only on Windows. So you can bracket
1539 * Windows-specific code in "\#ifdef G_OS_WIN32".
1543 * G_OS_UNIX:
1545 * This macro is defined only on UNIX. So you can bracket
1546 * UNIX-specific code in "\#ifdef G_OS_UNIX".
1550 * G_DIR_SEPARATOR:
1552 * The directory separator character.
1553 * This is '/' on UNIX machines and '\' under Windows.
1557 * G_DIR_SEPARATOR_S:
1559 * The directory separator as a string.
1560 * This is "/" on UNIX machines and "\" under Windows.
1564 * G_IS_DIR_SEPARATOR:
1565 * @c: a character
1567 * Checks whether a character is a directory
1568 * separator. It returns %TRUE for '/' on UNIX
1569 * machines and for '\' or '/' under Windows.
1571 * Since: 2.6
1575 * G_SEARCHPATH_SEPARATOR:
1577 * The search path separator character.
1578 * This is ':' on UNIX machines and ';' under Windows.
1582 * G_SEARCHPATH_SEPARATOR_S:
1584 * The search path separator as a string.
1585 * This is ":" on UNIX machines and ";" under Windows.
1589 * TRUE:
1591 * Defines the %TRUE value for the #gboolean type.
1595 * FALSE:
1597 * Defines the %FALSE value for the #gboolean type.
1601 * NULL:
1603 * Defines the standard %NULL pointer.
1607 * MIN:
1608 * @a: a numeric value
1609 * @b: a numeric value
1611 * Calculates the minimum of @a and @b.
1613 * Returns: the minimum of @a and @b.
1617 * MAX:
1618 * @a: a numeric value
1619 * @b: a numeric value
1621 * Calculates the maximum of @a and @b.
1623 * Returns: the maximum of @a and @b.
1627 * ABS:
1628 * @a: a numeric value
1630 * Calculates the absolute value of @a.
1631 * The absolute value is simply the number with any negative sign taken away.
1633 * For example,
1634 * - ABS(-10) is 10.
1635 * - ABS(10) is also 10.
1637 * Returns: the absolute value of @a.
1641 * CLAMP:
1642 * @x: the value to clamp
1643 * @low: the minimum value allowed
1644 * @high: the maximum value allowed
1646 * Ensures that @x is between the limits set by @low and @high. If @low is
1647 * greater than @high the result is undefined.
1649 * For example,
1650 * - CLAMP(5, 10, 15) is 10.
1651 * - CLAMP(15, 5, 10) is 10.
1652 * - CLAMP(20, 15, 25) is 20.
1654 * Returns: the value of @x clamped to the range between @low and @high
1658 * G_STRUCT_MEMBER:
1659 * @member_type: the type of the struct field
1660 * @struct_p: a pointer to a struct
1661 * @struct_offset: the offset of the field from the start of the struct,
1662 * in bytes
1664 * Returns a member of a structure at a given offset, using the given type.
1666 * Returns: the struct member
1670 * G_STRUCT_MEMBER_P:
1671 * @struct_p: a pointer to a struct
1672 * @struct_offset: the offset from the start of the struct, in bytes
1674 * Returns an untyped pointer to a given offset of a struct.
1676 * Returns: an untyped pointer to @struct_p plus @struct_offset bytes
1680 * G_STRUCT_OFFSET:
1681 * @struct_type: a structure type, e.g. #GtkWidget
1682 * @member: a field in the structure, e.g. @window
1684 * Returns the offset, in bytes, of a member of a struct.
1686 * Returns: the offset of @member from the start of @struct_type
1690 * G_CONST_RETURN:
1692 * If %G_DISABLE_CONST_RETURNS is defined, this macro expands
1693 * to nothing. By default, the macro expands to const. The macro
1694 * can be used in place of const for functions that return a value
1695 * that should not be modified. The purpose of this macro is to allow
1696 * us to turn on const for returned constant strings by default, while
1697 * allowing programmers who find that annoying to turn it off. This macro
1698 * should only be used for return values and for "out" parameters, it
1699 * doesn't make sense for "in" parameters.
1701 * Deprecated: 2.30: API providers should replace all existing uses with
1702 * const and API consumers should adjust their code accordingly
1706 * G_N_ELEMENTS:
1707 * @arr: the array
1709 * Determines the number of elements in an array. The array must be
1710 * declared so the compiler knows its size at compile-time; this
1711 * macro will not work on an array allocated on the heap, only static
1712 * arrays or arrays on the stack.
1715 /* Miscellaneous Macros {{{1 */
1718 * SECTION:macros_misc
1719 * @title: Miscellaneous Macros
1720 * @short_description: specialized macros which are not used often
1722 * These macros provide more specialized features which are not
1723 * needed so often by application programmers.
1727 * G_INLINE_FUNC:
1729 * This macro is used to export function prototypes so they can be linked
1730 * with an external version when no inlining is performed. The file which
1731 * implements the functions should define %G_IMPLEMENTS_INLINES
1732 * before including the headers which contain %G_INLINE_FUNC declarations.
1733 * Since inlining is very compiler-dependent using these macros correctly
1734 * is very difficult. Their use is strongly discouraged.
1736 * This macro is often mistaken for a replacement for the inline keyword;
1737 * inline is already declared in a portable manner in the GLib headers
1738 * and can be used normally.
1742 * G_STMT_START:
1744 * Used within multi-statement macros so that they can be used in places
1745 * where only one statement is expected by the compiler.
1749 * G_STMT_END:
1751 * Used within multi-statement macros so that they can be used in places
1752 * where only one statement is expected by the compiler.
1756 * G_BEGIN_DECLS:
1758 * Used (along with #G_END_DECLS) to bracket header files. If the
1759 * compiler in use is a C++ compiler, adds extern "C"
1760 * around the header.
1764 * G_END_DECLS:
1766 * Used (along with #G_BEGIN_DECLS) to bracket header files. If the
1767 * compiler in use is a C++ compiler, adds extern "C"
1768 * around the header.
1772 * G_VA_COPY:
1773 * @ap1: the va_list variable to place a copy of @ap2 in
1774 * @ap2: a va_list
1776 * Portable way to copy va_list variables.
1778 * In order to use this function, you must include string.h yourself,
1779 * because this macro may use memmove() and GLib does not include
1780 * string.h for you.
1784 * G_STRINGIFY:
1785 * @macro_or_string: a macro or a string
1787 * Accepts a macro or a string and converts it into a string after
1788 * preprocessor argument expansion. For example, the following code:
1790 * |[<!-- language="C" -->
1791 * #define AGE 27
1792 * const gchar *greeting = G_STRINGIFY (AGE) " today!";
1793 * ]|
1795 * is transformed by the preprocessor into (code equivalent to):
1797 * |[<!-- language="C" -->
1798 * const gchar *greeting = "27 today!";
1799 * ]|
1803 * G_PASTE:
1804 * @identifier1: an identifier
1805 * @identifier2: an identifier
1807 * Yields a new preprocessor pasted identifier
1808 * @identifier1identifier2 from its expanded
1809 * arguments @identifier1 and @identifier2. For example,
1810 * the following code:
1811 * |[<!-- language="C" -->
1812 * #define GET(traveller,method) G_PASTE(traveller_get_, method) (traveller)
1813 * const gchar *name = GET (traveller, name);
1814 * const gchar *quest = GET (traveller, quest);
1815 * GdkColor *favourite = GET (traveller, favourite_colour);
1816 * ]|
1818 * is transformed by the preprocessor into:
1819 * |[<!-- language="C" -->
1820 * const gchar *name = traveller_get_name (traveller);
1821 * const gchar *quest = traveller_get_quest (traveller);
1822 * GdkColor *favourite = traveller_get_favourite_colour (traveller);
1823 * ]|
1825 * Since: 2.20
1829 * G_STATIC_ASSERT:
1830 * @expr: a constant expression
1832 * The G_STATIC_ASSERT() macro lets the programmer check
1833 * a condition at compile time, the condition needs to
1834 * be compile time computable. The macro can be used in
1835 * any place where a typedef is valid.
1837 * A typedef is generally allowed in exactly the same places that
1838 * a variable declaration is allowed. For this reason, you should
1839 * not use G_STATIC_ASSERT() in the middle of blocks of code.
1841 * The macro should only be used once per source code line.
1843 * Since: 2.20
1847 * G_STATIC_ASSERT_EXPR:
1848 * @expr: a constant expression
1850 * The G_STATIC_ASSERT_EXPR() macro lets the programmer check
1851 * a condition at compile time. The condition needs to be
1852 * compile time computable.
1854 * Unlike G_STATIC_ASSERT(), this macro evaluates to an expression
1855 * and, as such, can be used in the middle of other expressions.
1856 * Its value should be ignored. This can be accomplished by placing
1857 * it as the first argument of a comma expression.
1859 * |[<!-- language="C" -->
1860 * #define ADD_ONE_TO_INT(x) \
1861 * (G_STATIC_ASSERT_EXPR(sizeof (x) == sizeof (int)), ((x) + 1))
1862 * ]|
1864 * Since: 2.30
1868 * G_GNUC_EXTENSION:
1870 * Expands to __extension__ when gcc is used as the compiler. This simply
1871 * tells gcc not to warn about the following non-standard code when compiling
1872 * with the `-pedantic` option.
1876 * G_GNUC_CONST:
1878 * Expands to the GNU C const function attribute if the compiler is gcc.
1879 * Declaring a function as const enables better optimization of calls to
1880 * the function. A const function doesn't examine any values except its
1881 * parameters, and has no effects except its return value.
1883 * Place the attribute after the declaration, just before the semicolon.
1885 * See the GNU C documentation for more details.
1887 * A function that has pointer arguments and examines the data pointed to
1888 * must not be declared const. Likewise, a function that calls a non-const
1889 * function usually must not be const. It doesn't make sense for a const
1890 * function to return void.
1894 * G_GNUC_PURE:
1896 * Expands to the GNU C pure function attribute if the compiler is gcc.
1897 * Declaring a function as pure enables better optimization of calls to
1898 * the function. A pure function has no effects except its return value
1899 * and the return value depends only on the parameters and/or global
1900 * variables.
1902 * Place the attribute after the declaration, just before the semicolon.
1904 * See the GNU C documentation for more details.
1908 * G_GNUC_MALLOC:
1910 * Expands to the GNU C malloc function attribute if the compiler is gcc.
1911 * Declaring a function as malloc enables better optimization of the function.
1912 * A function can have the malloc attribute if it returns a pointer which is
1913 * guaranteed to not alias with any other pointer when the function returns
1914 * (in practice, this means newly allocated memory).
1916 * Place the attribute after the declaration, just before the semicolon.
1918 * See the GNU C documentation for more details.
1920 * Since: 2.6
1924 * G_GNUC_ALLOC_SIZE:
1925 * @x: the index of the argument specifying the allocation size
1927 * Expands to the GNU C alloc_size function attribute if the compiler
1928 * is a new enough gcc. This attribute tells the compiler that the
1929 * function returns a pointer to memory of a size that is specified
1930 * by the @xth function parameter.
1932 * Place the attribute after the function declaration, just before the
1933 * semicolon.
1935 * See the GNU C documentation for more details.
1937 * Since: 2.18
1941 * G_GNUC_ALLOC_SIZE2:
1942 * @x: the index of the argument specifying one factor of the allocation size
1943 * @y: the index of the argument specifying the second factor of the allocation size
1945 * Expands to the GNU C alloc_size function attribute if the compiler is a
1946 * new enough gcc. This attribute tells the compiler that the function returns
1947 * a pointer to memory of a size that is specified by the product of two
1948 * function parameters.
1950 * Place the attribute after the function declaration, just before the
1951 * semicolon.
1953 * See the GNU C documentation for more details.
1955 * Since: 2.18
1959 * G_GNUC_DEPRECATED:
1961 * Expands to the GNU C deprecated attribute if the compiler is gcc.
1962 * It can be used to mark typedefs, variables and functions as deprecated.
1963 * When called with the `-Wdeprecated-declarations` option,
1964 * gcc will generate warnings when deprecated interfaces are used.
1966 * Place the attribute after the declaration, just before the semicolon.
1968 * See the GNU C documentation for more details.
1970 * Since: 2.2
1974 * G_GNUC_DEPRECATED_FOR:
1975 * @f: the intended replacement for the deprecated symbol,
1976 * such as the name of a function
1978 * Like %G_GNUC_DEPRECATED, but names the intended replacement for the
1979 * deprecated symbol if the version of gcc in use is new enough to support
1980 * custom deprecation messages.
1982 * Place the attribute after the declaration, just before the semicolon.
1984 * See the GNU C documentation for more details.
1986 * Note that if @f is a macro, it will be expanded in the warning message.
1987 * You can enclose it in quotes to prevent this. (The quotes will show up
1988 * in the warning, but it's better than showing the macro expansion.)
1990 * Since: 2.26
1994 * G_GNUC_BEGIN_IGNORE_DEPRECATIONS:
1996 * Tells gcc (if it is a new enough version) to temporarily stop emitting
1997 * warnings when functions marked with %G_GNUC_DEPRECATED or
1998 * %G_GNUC_DEPRECATED_FOR are called. This is useful for when you have
1999 * one deprecated function calling another one, or when you still have
2000 * regression tests for deprecated functions.
2002 * Use %G_GNUC_END_IGNORE_DEPRECATIONS to begin warning again. (If you
2003 * are not compiling with `-Wdeprecated-declarations` then neither macro
2004 * has any effect.)
2006 * This macro can be used either inside or outside of a function body,
2007 * but must appear on a line by itself.
2009 * Since: 2.32
2013 * G_GNUC_END_IGNORE_DEPRECATIONS:
2015 * Undoes the effect of %G_GNUC_BEGIN_IGNORE_DEPRECATIONS, telling
2016 * gcc to begin outputting warnings again (assuming those warnings
2017 * had been enabled to begin with).
2019 * This macro can be used either inside or outside of a function body,
2020 * but must appear on a line by itself.
2022 * Since: 2.32
2026 * G_DEPRECATED:
2028 * This macro is similar to %G_GNUC_DEPRECATED, and can be used to mark
2029 * functions declarations as deprecated. Unlike %G_GNUC_DEPRECATED, it is
2030 * meant to be portable across different compilers and must be placed
2031 * before the function declaration.
2033 * Since: 2.32
2037 * G_DEPRECATED_FOR:
2038 * @f: the name of the function that this function was deprecated for
2040 * This macro is similar to %G_GNUC_DEPRECATED_FOR, and can be used to mark
2041 * functions declarations as deprecated. Unlike %G_GNUC_DEPRECATED_FOR, it
2042 * is meant to be portable across different compilers and must be placed
2043 * before the function declaration.
2045 * Since: 2.32
2049 * G_UNAVAILABLE:
2050 * @maj: the major version that introduced the symbol
2051 * @min: the minor version that introduced the symbol
2053 * This macro can be used to mark a function declaration as unavailable.
2054 * It must be placed before the function declaration. Use of a function
2055 * that has been annotated with this macros will produce a compiler warning.
2057 * Since: 2.32
2061 * GLIB_DISABLE_DEPRECATION_WARNINGS:
2063 * A macro that should be defined before including the glib.h header.
2064 * If it is defined, no compiler warnings will be produced for uses
2065 * of deprecated GLib APIs.
2069 * G_GNUC_NORETURN:
2071 * Expands to the GNU C noreturn function attribute if the compiler is gcc.
2072 * It is used for declaring functions which never return. It enables
2073 * optimization of the function, and avoids possible compiler warnings.
2075 * Place the attribute after the declaration, just before the semicolon.
2077 * See the GNU C documentation for more details.
2081 * G_GNUC_UNUSED:
2083 * Expands to the GNU C unused function attribute if the compiler is gcc.
2084 * It is used for declaring functions and arguments which may never be used.
2085 * It avoids possible compiler warnings.
2087 * For functions, place the attribute after the declaration, just before the
2088 * semicolon. For arguments, place the attribute at the beginning of the
2089 * argument declaration.
2091 * |[<!-- language="C" -->
2092 * void my_unused_function (G_GNUC_UNUSED gint unused_argument,
2093 * gint other_argument) G_GNUC_UNUSED;
2094 * ]|
2096 * See the GNU C documentation for more details.
2100 * G_GNUC_PRINTF:
2101 * @format_idx: the index of the argument corresponding to the
2102 * format string (The arguments are numbered from 1)
2103 * @arg_idx: the index of the first of the format arguments
2105 * Expands to the GNU C format function attribute if the compiler is gcc.
2106 * This is used for declaring functions which take a variable number of
2107 * arguments, with the same syntax as printf(). It allows the compiler
2108 * to type-check the arguments passed to the function.
2110 * Place the attribute after the function declaration, just before the
2111 * semicolon.
2113 * See the GNU C documentation for more details.
2115 * |[<!-- language="C" -->
2116 * gint g_snprintf (gchar *string,
2117 * gulong n,
2118 * gchar const *format,
2119 * ...) G_GNUC_PRINTF (3, 4);
2120 * ]|
2124 * G_GNUC_SCANF:
2125 * @format_idx: the index of the argument corresponding to
2126 * the format string (The arguments are numbered from 1)
2127 * @arg_idx: the index of the first of the format arguments
2129 * Expands to the GNU C format function attribute if the compiler is gcc.
2130 * This is used for declaring functions which take a variable number of
2131 * arguments, with the same syntax as scanf(). It allows the compiler
2132 * to type-check the arguments passed to the function.
2134 * See the GNU C documentation for details.
2138 * G_GNUC_FORMAT:
2139 * @arg_idx: the index of the argument
2141 * Expands to the GNU C format_arg function attribute if the compiler
2142 * is gcc. This function attribute specifies that a function takes a
2143 * format string for a printf(), scanf(), strftime() or strfmon() style
2144 * function and modifies it, so that the result can be passed to a printf(),
2145 * scanf(), strftime() or strfmon() style function (with the remaining
2146 * arguments to the format function the same as they would have been
2147 * for the unmodified string).
2149 * Place the attribute after the function declaration, just before the
2150 * semicolon.
2152 * See the GNU C documentation for more details.
2154 * |[<!-- language="C" -->
2155 * gchar *g_dgettext (gchar *domain_name, gchar *msgid) G_GNUC_FORMAT (2);
2156 * ]|
2160 * G_GNUC_NULL_TERMINATED:
2162 * Expands to the GNU C sentinel function attribute if the compiler is gcc.
2163 * This function attribute only applies to variadic functions and instructs
2164 * the compiler to check that the argument list is terminated with an
2165 * explicit %NULL.
2167 * Place the attribute after the declaration, just before the semicolon.
2169 * See the GNU C documentation for more details.
2171 * Since: 2.8
2175 * G_GNUC_WARN_UNUSED_RESULT:
2177 * Expands to the GNU C warn_unused_result function attribute if the compiler
2178 * is gcc. This function attribute makes the compiler emit a warning if the
2179 * result of a function call is ignored.
2181 * Place the attribute after the declaration, just before the semicolon.
2183 * See the GNU C documentation for more details.
2185 * Since: 2.10
2189 * G_GNUC_FUNCTION:
2191 * Expands to "" on all modern compilers, and to __FUNCTION__ on gcc
2192 * version 2.x. Don't use it.
2194 * Deprecated: 2.16: Use G_STRFUNC() instead
2198 * G_GNUC_PRETTY_FUNCTION:
2200 * Expands to "" on all modern compilers, and to __PRETTY_FUNCTION__
2201 * on gcc version 2.x. Don't use it.
2203 * Deprecated: 2.16: Use G_STRFUNC() instead
2207 * G_GNUC_NO_INSTRUMENT:
2209 * Expands to the GNU C no_instrument_function function attribute if the
2210 * compiler is gcc. Functions with this attribute will not be instrumented
2211 * for profiling, when the compiler is called with the
2212 * `-finstrument-functions` option.
2214 * Place the attribute after the declaration, just before the semicolon.
2216 * See the GNU C documentation for more details.
2220 * G_GNUC_INTERNAL:
2222 * This attribute can be used for marking library functions as being used
2223 * internally to the library only, which may allow the compiler to handle
2224 * function calls more efficiently. Note that static functions do not need
2225 * to be marked as internal in this way. See the GNU C documentation for
2226 * details.
2228 * When using a compiler that supports the GNU C hidden visibility attribute,
2229 * this macro expands to __attribute__((visibility("hidden"))).
2230 * When using the Sun Studio compiler, it expands to __hidden.
2232 * Note that for portability, the attribute should be placed before the
2233 * function declaration. While GCC allows the macro after the declaration,
2234 * Sun Studio does not.
2236 * |[<!-- language="C" -->
2237 * G_GNUC_INTERNAL
2238 * void _g_log_fallback_handler (const gchar *log_domain,
2239 * GLogLevelFlags log_level,
2240 * const gchar *message,
2241 * gpointer unused_data);
2242 * ]|
2244 * Since: 2.6
2248 * G_GNUC_MAY_ALIAS:
2250 * Expands to the GNU C may_alias type attribute if the compiler is gcc.
2251 * Types with this attribute will not be subjected to type-based alias
2252 * analysis, but are assumed to alias with any other type, just like char.
2254 * See the GNU C documentation for details.
2256 * Since: 2.14
2260 * G_LIKELY:
2261 * @expr: the expression
2263 * Hints the compiler that the expression is likely to evaluate to
2264 * a true value. The compiler may use this information for optimizations.
2266 * |[<!-- language="C" -->
2267 * if (G_LIKELY (random () != 1))
2268 * g_print ("not one");
2269 * ]|
2271 * Returns: the value of @expr
2273 * Since: 2.2
2277 * G_UNLIKELY:
2278 * @expr: the expression
2280 * Hints the compiler that the expression is unlikely to evaluate to
2281 * a true value. The compiler may use this information for optimizations.
2283 * |[<!-- language="C" -->
2284 * if (G_UNLIKELY (random () == 1))
2285 * g_print ("a random one");
2286 * ]|
2288 * Returns: the value of @expr
2290 * Since: 2.2
2294 * G_STRLOC:
2296 * Expands to a string identifying the current code position.
2300 * G_STRFUNC:
2302 * Expands to a string identifying the current function.
2304 * Since: 2.4
2308 * G_HAVE_GNUC_VISIBILITY:
2310 * Defined to 1 if gcc-style visibility handling is supported.
2313 /* g_auto(), g_autoptr() and helpers {{{1 */
2316 * g_auto:
2317 * @TypeName: a supported variable type
2319 * Helper to declare a variable with automatic cleanup.
2321 * The variable is cleaned up in a way appropriate to its type when the
2322 * variable goes out of scope. The type must support this.
2324 * This feature is only supported on GCC and clang. This macro is not
2325 * defined on other compilers and should not be used in programs that
2326 * are intended to be portable to those compilers.
2328 * This is meant to be used with stack-allocated structures and
2329 * non-pointer types. For the (more commonly used) pointer version, see
2330 * g_autoptr().
2332 * This macro can be used to avoid having to do explicit cleanups of
2333 * local variables when exiting functions. It often vastly simplifies
2334 * handling of error conditions, removing the need for various tricks
2335 * such as 'goto out' or repeating of cleanup code. It is also helpful
2336 * for non-error cases.
2338 * Consider the following example:
2340 * |[
2341 * GVariant *
2342 * my_func(void)
2344 * g_auto(GQueue) queue = G_QUEUE_INIT;
2345 * g_auto(GVariantBuilder) builder;
2347 * g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT);
2349 * ...
2351 * if (error_condition)
2352 * return NULL;
2354 * ...
2356 * return g_variant_builder_end (&builder);
2358 * ]|
2360 * You must initialise the variable in some way -- either by use of an
2361 * initialiser or by ensuring that an _init function will be called on
2362 * it unconditionally before it goes out of scope.
2364 * Since: 2.44
2368 * g_autoptr:
2369 * @TypeName: a supported variable type
2371 * Helper to declare a pointer variable with automatic cleanup.
2373 * The variable is cleaned up in a way appropriate to its type when the
2374 * variable goes out of scope. The type must support this.
2376 * This feature is only supported on GCC and clang. This macro is not
2377 * defined on other compilers and should not be used in programs that
2378 * are intended to be portable to those compilers.
2380 * This is meant to be used to declare pointers to types with cleanup
2381 * functions. The type of the variable is a pointer to @TypeName. You
2382 * must not add your own '*'.
2384 * This macro can be used to avoid having to do explicit cleanups of
2385 * local variables when exiting functions. It often vastly simplifies
2386 * handling of error conditions, removing the need for various tricks
2387 * such as 'goto out' or repeating of cleanup code. It is also helpful
2388 * for non-error cases.
2390 * Consider the following example:
2392 * |[
2393 * gboolean
2394 * check_exists(GVariant *dict)
2396 * g_autoptr(GVariant) dirname;
2397 * g_autoptr(GVariant) basename = NULL;
2398 * g_autoptr(gchar) path = NULL;
2400 * dirname = g_variant_lookup_value (dict, "dirname", G_VARIANT_TYPE_STRING);
2402 * if (dirname == NULL)
2403 * return FALSE;
2405 * basename = g_variant_lookup_value (dict, "basename", G_VARIANT_TYPE_STRING);
2407 * if (basename == NULL)
2408 * return FALSE;
2410 * path = g_build_filename (g_variant_get_string (dirname, NULL),
2411 * g_variant_get_string (basename, NULL),
2412 * NULL);
2414 * return g_access (path, R_OK) == 0;
2416 * ]|
2418 * You must initialise the variable in some way -- either by use of an
2419 * initialiser or by ensuring that it is assigned to unconditionally
2420 * before it goes out of scope.
2422 * Since: 2.44
2426 * g_autofree:
2428 * Macro to add an attribute to pointer variable to ensure automatic
2429 * cleanup using g_free().
2431 * This macro differs from g_autoptr() in that it is an attribute supplied
2432 * before the type name, rather than wrapping the type definition. Instead
2433 * of using a type-specific lookup, this macro always calls g_free() directly.
2435 * This means it's useful for any type that is returned from
2436 * g_malloc().
2438 * Otherwise, this macro has similar constraints as g_autoptr() - only
2439 * supported on GCC and clang, the variable must be initialized, etc.
2441 * |[
2442 * gboolean
2443 * operate_on_malloc_buf (void)
2445 * g_autofree guint8* membuf = NULL;
2447 * membuf = g_malloc (8192);
2449 * /* Some computation on membuf */
2451 * /* membuf will be automatically freed here */
2452 * return TRUE;
2454 * ]|
2456 * Since: 2.44
2460 * G_DEFINE_AUTOPTR_CLEANUP_FUNC:
2461 * @TypeName: a type name to define a g_autoptr() cleanup function for
2462 * @func: the cleanup function
2464 * Defines the appropriate cleanup function for a pointer type.
2466 * The function will not be called if the variable to be cleaned up
2467 * contains %NULL.
2469 * This will typically be the _free() or _unref() function for the given
2470 * type.
2472 * With this definition, it will be possible to use g_autoptr() with
2473 * @TypeName.
2475 * |[
2476 * G_DEFINE_AUTOPTR_CLEANUP_FUNC(GObject, g_object_unref)
2477 * ]|
2479 * This macro should be used unconditionally; it is a no-op on compilers
2480 * where cleanup is not supported.
2482 * Since: 2.44
2486 * G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC:
2487 * @TypeName: a type name to define a g_auto() cleanup function for
2488 * @func: the clear function
2490 * Defines the appropriate cleanup function for a type.
2492 * This will typically be the _clear() function for the given type.
2494 * With this definition, it will be possible to use g_auto() with
2495 * @TypeName.
2497 * |[
2498 * G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(GQueue, g_queue_clear)
2499 * ]|
2501 * This macro should be used unconditionally; it is a no-op on compilers
2502 * where cleanup is not supported.
2504 * Since: 2.44
2508 * G_DEFINE_AUTO_CLEANUP_FREE_FUNC:
2509 * @TypeName: a type name to define a g_auto() cleanup function for
2510 * @func: the free function
2511 * @none: the "none" value for the type
2513 * Defines the appropriate cleanup function for a type.
2515 * With this definition, it will be possible to use g_auto() with
2516 * @TypeName.
2518 * This function will be rarely used. It is used with pointer-based
2519 * typedefs and non-pointer types where the value of the variable
2520 * represents a resource that must be freed. Two examples are #GStrv
2521 * and file descriptors.
2523 * @none specifies the "none" value for the type in question. It is
2524 * probably something like %NULL or -1. If the variable is found to
2525 * contain this value then the free function will not be called.
2527 * |[
2528 * G_DEFINE_AUTO_CLEANUP_FREE_FUNC(GStrv, g_strfreev, NULL)
2529 * ]|
2531 * This macro should be used unconditionally; it is a no-op on compilers
2532 * where cleanup is not supported.
2534 * Since: 2.44
2537 /* Windows Compatibility Functions {{{1 */
2540 * SECTION:windows
2541 * @title: Windows Compatibility Functions
2542 * @short_description: UNIX emulation on Windows
2544 * These functions provide some level of UNIX emulation on the
2545 * Windows platform. If your application really needs the POSIX
2546 * APIs, we suggest you try the Cygwin project.
2550 * MAXPATHLEN:
2552 * Provided for UNIX emulation on Windows; equivalent to UNIX
2553 * macro %MAXPATHLEN, which is the maximum length of a filename
2554 * (including full path).
2558 * G_WIN32_DLLMAIN_FOR_DLL_NAME:
2559 * @static: empty or "static"
2560 * @dll_name: the name of the (pointer to the) char array where
2561 * the DLL name will be stored. If this is used, you must also
2562 * include `windows.h`. If you need a more complex DLL entry
2563 * point function, you cannot use this
2565 * On Windows, this macro defines a DllMain() function that stores
2566 * the actual DLL name that the code being compiled will be included in.
2568 * On non-Windows platforms, expands to nothing.
2572 * G_WIN32_HAVE_WIDECHAR_API:
2574 * On Windows, this macro defines an expression which evaluates to
2575 * %TRUE if the code is running on a version of Windows where the wide
2576 * character versions of the Win32 API functions, and the wide character
2577 * versions of the C library functions work. (They are always present in
2578 * the DLLs, but don't work on Windows 9x and Me.)
2580 * On non-Windows platforms, it is not defined.
2582 * Since: 2.6
2587 * G_WIN32_IS_NT_BASED:
2589 * On Windows, this macro defines an expression which evaluates to
2590 * %TRUE if the code is running on an NT-based Windows operating system.
2592 * On non-Windows platforms, it is not defined.
2594 * Since: 2.6
2597 /* Epilogue {{{1 */
2598 /* vim: set foldmethod=marker: */