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.1 of the License, 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
26 /* Basic types {{{1 */
31 * @short_description: standard GLib types, defined for ease-of-use
34 * GLib defines a number of commonly used types, which can be divided
35 * into several groups:
36 * - New types which are not part of standard C (but are defined in
37 * various C standard library header files) — #gboolean, #gssize.
38 * - Integer types which are guaranteed to be the same size across
39 * all platforms — #gint8, #guint8, #gint16, #guint16, #gint32,
40 * #guint32, #gint64, #guint64.
41 * - Types which are easier to use than their standard C counterparts -
42 * #gpointer, #gconstpointer, #guchar, #guint, #gushort, #gulong.
43 * - Types which correspond exactly to standard C types, but are
44 * included for completeness — #gchar, #gint, #gshort, #glong,
46 * - Types which correspond exactly to standard C99 types, but are available
47 * to use even if your compiler does not support C99 — #gsize, #goffset,
48 * #gintptr, #guintptr.
50 * GLib also defines macros for the limits of some of the standard
51 * integer and floating point types, as well as macros for suitable
52 * printf() formats for these types.
58 * A standard boolean type.
59 * Variables of this type should only contain the value
67 * #gpointer looks better and is easier to use than void*.
73 * An untyped pointer to constant data.
74 * The data pointed to should not be changed.
76 * This is typically used in function prototypes to indicate
77 * that the data pointed to will not be altered by the function.
83 * Corresponds to the standard C char type.
89 * Corresponds to the standard C unsigned char type.
95 * Corresponds to the standard C int type.
96 * Values of this type can range from #G_MININT to #G_MAXINT.
102 * The minimum value which can be held in a #gint.
108 * The maximum value which can be held in a #gint.
114 * Corresponds to the standard C unsigned int type.
115 * Values of this type can range from 0 to #G_MAXUINT.
121 * The maximum value which can be held in a #guint.
127 * Corresponds to the standard C short type.
128 * Values of this type can range from #G_MINSHORT to #G_MAXSHORT.
134 * The minimum value which can be held in a #gshort.
140 * The maximum value which can be held in a #gshort.
146 * Corresponds to the standard C unsigned short type.
147 * Values of this type can range from 0 to #G_MAXUSHORT.
153 * The maximum value which can be held in a #gushort.
159 * Corresponds to the standard C long type.
160 * Values of this type can range from #G_MINLONG to #G_MAXLONG.
166 * The minimum value which can be held in a #glong.
172 * The maximum value which can be held in a #glong.
178 * Corresponds to the standard C unsigned long type.
179 * Values of this type can range from 0 to #G_MAXULONG.
185 * The maximum value which can be held in a #gulong.
191 * A signed integer guaranteed to be 8 bits on all platforms.
192 * Values of this type can range from #G_MININT8 (= -128) to
193 * #G_MAXINT8 (= 127).
199 * The minimum value which can be held in a #gint8.
207 * The maximum value which can be held in a #gint8.
215 * An unsigned integer guaranteed to be 8 bits on all platforms.
216 * Values of this type can range from 0 to #G_MAXUINT8 (= 255).
222 * The maximum value which can be held in a #guint8.
230 * A signed integer guaranteed to be 16 bits on all platforms.
231 * Values of this type can range from #G_MININT16 (= -32,768) to
232 * #G_MAXINT16 (= 32,767).
234 * To print or scan values of this type, use
235 * %G_GINT16_MODIFIER and/or %G_GINT16_FORMAT.
241 * The minimum value which can be held in a #gint16.
249 * The maximum value which can be held in a #gint16.
257 * The platform dependent length modifier for conversion specifiers
258 * for scanning and printing values of type #gint16 or #guint16. It
259 * is a string literal, but doesn't include the percent-sign, such
260 * that you can add precision and length modifiers between percent-sign
261 * and conversion specifier and append a conversion specifier.
263 * The following example prints "0x7b";
264 * |[<!-- language="C" -->
265 * gint16 value = 123;
266 * g_print ("%#" G_GINT16_MODIFIER "x", value);
275 * This is the platform dependent conversion specifier for scanning and
276 * printing values of type #gint16. It is a string literal, but doesn't
277 * include the percent-sign, such that you can add precision and length
278 * modifiers between percent-sign and conversion specifier.
280 * |[<!-- language="C" -->
283 * sscanf ("42", "%" G_GINT16_FORMAT, &in)
285 * g_print ("%" G_GINT32_FORMAT, out);
292 * An unsigned integer guaranteed to be 16 bits on all platforms.
293 * Values of this type can range from 0 to #G_MAXUINT16 (= 65,535).
295 * To print or scan values of this type, use
296 * %G_GINT16_MODIFIER and/or %G_GUINT16_FORMAT.
302 * The maximum value which can be held in a #guint16.
310 * This is the platform dependent conversion specifier for scanning
311 * and printing values of type #guint16. See also #G_GINT16_FORMAT
317 * A signed integer guaranteed to be 32 bits on all platforms.
318 * Values of this type can range from #G_MININT32 (= -2,147,483,648)
319 * to #G_MAXINT32 (= 2,147,483,647).
321 * To print or scan values of this type, use
322 * %G_GINT32_MODIFIER and/or %G_GINT32_FORMAT.
328 * The minimum value which can be held in a #gint32.
336 * The maximum value which can be held in a #gint32.
344 * The platform dependent length modifier for conversion specifiers
345 * for scanning and printing values of type #gint32 or #guint32. It
346 * is a string literal. See also #G_GINT16_MODIFIER.
354 * This is the platform dependent conversion specifier for scanning
355 * and printing values of type #gint32. See also #G_GINT16_FORMAT.
361 * An unsigned integer guaranteed to be 32 bits on all platforms.
362 * Values of this type can range from 0 to #G_MAXUINT32 (= 4,294,967,295).
364 * To print or scan values of this type, use
365 * %G_GINT32_MODIFIER and/or %G_GUINT32_FORMAT.
371 * The maximum value which can be held in a #guint32.
379 * This is the platform dependent conversion specifier for scanning
380 * and printing values of type #guint32. See also #G_GINT16_FORMAT.
386 * A signed integer guaranteed to be 64 bits on all platforms.
387 * Values of this type can range from #G_MININT64
388 * (= -9,223,372,036,854,775,808) to #G_MAXINT64
389 * (= 9,223,372,036,854,775,807).
391 * To print or scan values of this type, use
392 * %G_GINT64_MODIFIER and/or %G_GINT64_FORMAT.
398 * The minimum value which can be held in a #gint64.
404 * The maximum value which can be held in a #gint64.
410 * The platform dependent length modifier for conversion specifiers
411 * for scanning and printing values of type #gint64 or #guint64.
412 * It is a string literal.
414 * Some platforms do not support printing 64-bit integers, even
415 * though the types are supported. On such platforms %G_GINT64_MODIFIER
424 * This is the platform dependent conversion specifier for scanning
425 * and printing values of type #gint64. See also #G_GINT16_FORMAT.
427 * Some platforms do not support scanning and printing 64-bit integers,
428 * even though the types are supported. On such platforms %G_GINT64_FORMAT
429 * is not defined. Note that scanf() may not support 64-bit integers, even
430 * if %G_GINT64_FORMAT is defined. Due to its weak error handling, scanf()
431 * is not recommended for parsing anyway; consider using g_ascii_strtoull()
438 * An unsigned integer guaranteed to be 64-bits on all platforms.
439 * Values of this type can range from 0 to #G_MAXUINT64
440 * (= 18,446,744,073,709,551,615).
442 * To print or scan values of this type, use
443 * %G_GINT64_MODIFIER and/or %G_GUINT64_FORMAT.
449 * The maximum value which can be held in a #guint64.
455 * This is the platform dependent conversion specifier for scanning
456 * and printing values of type #guint64. See also #G_GINT16_FORMAT.
458 * Some platforms do not support scanning and printing 64-bit integers,
459 * even though the types are supported. On such platforms %G_GUINT64_FORMAT
460 * is not defined. Note that scanf() may not support 64-bit integers, even
461 * if %G_GINT64_FORMAT is defined. Due to its weak error handling, scanf()
462 * is not recommended for parsing anyway; consider using g_ascii_strtoull()
468 * @val: a literal integer value, e.g. 0x1d636b02300a7aa7
470 * This macro is used to insert 64-bit integer literals
471 * into the source code.
475 * G_GUINT64_CONSTANT:
476 * @val: a literal integer value, e.g. 0x1d636b02300a7aa7U
478 * This macro is used to insert 64-bit unsigned integer
479 * literals into the source code.
487 * Corresponds to the standard C float type.
488 * Values of this type can range from -#G_MAXFLOAT to #G_MAXFLOAT.
494 * The minimum positive value which can be held in a #gfloat.
496 * If you are interested in the smallest value which can be held
497 * in a #gfloat, use -%G_MAXFLOAT.
503 * The maximum value which can be held in a #gfloat.
509 * Corresponds to the standard C double type.
510 * Values of this type can range from -#G_MAXDOUBLE to #G_MAXDOUBLE.
516 * The minimum positive value which can be held in a #gdouble.
518 * If you are interested in the smallest value which can be held
519 * in a #gdouble, use -%G_MAXDOUBLE.
525 * The maximum value which can be held in a #gdouble.
531 * An unsigned integer type of the result of the sizeof operator,
532 * corresponding to the size_t type defined in C99.
533 * This type is wide enough to hold the numeric value of a pointer,
534 * so it is usually 32 bit wide on a 32-bit platform and 64 bit wide
535 * on a 64-bit platform. Values of this type can range from 0 to
538 * To print or scan values of this type, use
539 * %G_GSIZE_MODIFIER and/or %G_GSIZE_FORMAT.
545 * The maximum value which can be held in a #gsize.
553 * The platform dependent length modifier for conversion specifiers
554 * for scanning and printing values of type #gsize. It
555 * is a string literal.
563 * This is the platform dependent conversion specifier for scanning
564 * and printing values of type #gsize. See also #G_GINT16_FORMAT.
572 * A signed variant of #gsize, corresponding to the
573 * ssize_t defined on most platforms.
574 * Values of this type can range from #G_MINSSIZE
577 * To print or scan values of this type, use
578 * %G_GSSIZE_MODIFIER and/or %G_GSSIZE_FORMAT.
584 * The minimum value which can be held in a #gssize.
592 * The maximum value which can be held in a #gssize.
600 * This is the platform dependent conversion specifier for scanning
601 * and printing values of type #gssize. See also #G_GINT16_FORMAT.
609 * The platform dependent length modifier for conversion specifiers
610 * for scanning and printing values of type #gssize. It
611 * is a string literal.
619 * A signed integer type that is used for file offsets,
620 * corresponding to the POSIX type `off_t` as if compiling with
621 * `_FILE_OFFSET_BITS` set to 64. #goffset is always 64 bits wide, even on
622 * 32-bit architectures.
623 * Values of this type can range from #G_MINOFFSET to
626 * To print or scan values of this type, use
627 * %G_GOFFSET_MODIFIER and/or %G_GOFFSET_FORMAT.
635 * The minimum value which can be held in a #goffset.
641 * The maximum value which can be held in a #goffset.
645 * G_GOFFSET_MODIFIER:
647 * The platform dependent length modifier for conversion specifiers
648 * for scanning and printing values of type #goffset. It is a string
649 * literal. See also #G_GINT64_MODIFIER.
657 * This is the platform dependent conversion specifier for scanning
658 * and printing values of type #goffset. See also #G_GINT64_FORMAT.
664 * G_GOFFSET_CONSTANT:
665 * @val: a literal integer value, e.g. 0x1d636b02300a7aa7
667 * This macro is used to insert #goffset 64-bit integer literals
668 * into the source code.
670 * See also #G_GINT64_CONSTANT.
678 * Corresponds to the C99 type intptr_t,
679 * a signed integer type that can hold any pointer.
681 * To print or scan values of this type, use
682 * %G_GINTPTR_MODIFIER and/or %G_GINTPTR_FORMAT.
688 * G_GINTPTR_MODIFIER:
690 * The platform dependent length modifier for conversion specifiers
691 * for scanning and printing values of type #gintptr or #guintptr.
692 * It is a string literal.
700 * This is the platform dependent conversion specifier for scanning
701 * and printing values of type #gintptr.
709 * Corresponds to the C99 type uintptr_t,
710 * an unsigned integer type that can hold any pointer.
712 * To print or scan values of this type, use
713 * %G_GINTPTR_MODIFIER and/or %G_GUINTPTR_FORMAT.
721 * This is the platform dependent conversion specifier
722 * for scanning and printing values of type #guintptr.
727 /* Type conversion {{{1 */
730 * SECTION:type_conversion
731 * @title: Type Conversion Macros
732 * @short_description: portably storing integers in pointer variables
734 * Many times GLib, GTK+, and other libraries allow you to pass "user
735 * data" to a callback, in the form of a void pointer. From time to time
736 * you want to pass an integer instead of a pointer. You could allocate
737 * an integer, with something like:
738 * |[<!-- language="C" -->
739 * int *ip = g_new (int, 1);
742 * But this is inconvenient, and it's annoying to have to free the
743 * memory at some later time.
745 * Pointers are always at least 32 bits in size (on all platforms GLib
746 * intends to support). Thus you can store at least 32-bit integer values
747 * in a pointer value. Naively, you might try this, but it's incorrect:
748 * |[<!-- language="C" -->
754 * Again, that example was not correct, don't copy it.
755 * The problem is that on some systems you need to do this:
756 * |[<!-- language="C" -->
759 * p = (void*) (long) 42;
760 * i = (int) (long) p;
762 * The GLib macros GPOINTER_TO_INT(), GINT_TO_POINTER(), etc. take care
763 * to do the right thing on the every platform.
765 * Warning: You may not store pointers in integers. This is not
766 * portable in any way, shape or form. These macros only allow storing
767 * integers in pointers, and only preserve 32 bits of the integer; values
768 * outside the range of a 32-bit integer will be mangled.
773 * @i: integer to stuff into a pointer
775 * Stuffs an integer into a pointer type.
777 * Remember, you may not store pointers in integers. This is not portable
778 * in any way, shape or form. These macros only allow storing integers in
779 * pointers, and only preserve 32 bits of the integer; values outside the
780 * range of a 32-bit integer will be mangled.
785 * @p: pointer containing an integer
787 * Extracts an integer from a pointer. The integer must have
788 * been stored in the pointer with GINT_TO_POINTER().
790 * Remember, you may not store pointers in integers. This is not portable
791 * in any way, shape or form. These macros only allow storing integers in
792 * pointers, and only preserve 32 bits of the integer; values outside the
793 * range of a 32-bit integer will be mangled.
798 * @u: unsigned integer to stuff into the pointer
800 * Stuffs an unsigned integer into a pointer type.
805 * @p: pointer to extract an unsigned integer from
807 * Extracts an unsigned integer from a pointer. The integer must have
808 * been stored in the pointer with GUINT_TO_POINTER().
813 * @s: #gsize to stuff into the pointer
815 * Stuffs a #gsize into a pointer type.
820 * @p: pointer to extract a #gsize from
822 * Extracts a #gsize from a pointer. The #gsize must have
823 * been stored in the pointer with GSIZE_TO_POINTER().
826 /* Byte order {{{1 */
830 * @title: Byte Order Macros
831 * @short_description: a portable way to convert between different byte orders
833 * These macros provide a portable way to determine the host byte order
834 * and to convert values between different byte orders.
836 * The byte order is the order in which bytes are stored to create larger
837 * data types such as the #gint and #glong values.
838 * The host byte order is the byte order used on the current machine.
840 * Some processors store the most significant bytes (i.e. the bytes that
841 * hold the largest part of the value) first. These are known as big-endian
842 * processors. Other processors (notably the x86 family) store the most
843 * significant byte last. These are known as little-endian processors.
845 * Finally, to complicate matters, some other processors store the bytes in
846 * a rather curious order known as PDP-endian. For a 4-byte word, the 3rd
847 * most significant byte is stored first, then the 4th, then the 1st and
850 * Obviously there is a problem when these different processors communicate
851 * with each other, for example over networks or by using binary file formats.
852 * This is where these macros come in. They are typically used to convert
853 * values into a byte order which has been agreed on for use when
854 * communicating between different processors. The Internet uses what is
855 * known as 'network byte order' as the standard byte order (which is in
856 * fact the big-endian byte order).
858 * Note that the byte order conversion macros may evaluate their arguments
859 * multiple times, thus you should not use them with arguments which have
866 * The host byte order.
867 * This can be either #G_LITTLE_ENDIAN or #G_BIG_ENDIAN (support for
868 * #G_PDP_ENDIAN may be added in future.)
874 * Specifies one of the possible types of byte order.
881 * Specifies one of the possible types of byte order.
888 * Specifies one of the possible types of byte order
889 * (currently unused). See #G_BYTE_ORDER.
894 * @val: a 32-bit integer value in host byte order
896 * Converts a 32-bit integer value from host to network byte order.
898 * Returns: @val converted to network byte order
903 * @val: a 16-bit integer value in host byte order
905 * Converts a 16-bit integer value from host to network byte order.
907 * Returns: @val converted to network byte order
912 * @val: a 32-bit integer value in network byte order
914 * Converts a 32-bit integer value from network to host byte order.
916 * Returns: @val converted to host byte order.
921 * @val: a 16-bit integer value in network byte order
923 * Converts a 16-bit integer value from network to host byte order.
925 * Returns: @val converted to host byte order
930 * @val: a #gint value in big-endian byte order
932 * Converts a #gint value from big-endian to host byte order.
934 * Returns: @val converted to host byte order
939 * @val: a #gint value in little-endian byte order
941 * Converts a #gint value from little-endian to host byte order.
943 * Returns: @val converted to host byte order
948 * @val: a #gint value in host byte order
950 * Converts a #gint value from host byte order to big-endian.
952 * Returns: @val converted to big-endian byte order
957 * @val: a #gint value in host byte order
959 * Converts a #gint value from host byte order to little-endian.
961 * Returns: @val converted to little-endian byte order
966 * @val: a #guint value in big-endian byte order
968 * Converts a #guint value from big-endian to host byte order.
970 * Returns: @val converted to host byte order
975 * @val: a #guint value in little-endian byte order
977 * Converts a #guint value from little-endian to host byte order.
979 * Returns: @val converted to host byte order
984 * @val: a #guint value in host byte order
986 * Converts a #guint value from host byte order to big-endian.
988 * Returns: @val converted to big-endian byte order
993 * @val: a #guint value in host byte order
995 * Converts a #guint value from host byte order to little-endian.
997 * Returns: @val converted to little-endian byte order.
1002 * @val: a #glong value in big-endian byte order
1004 * Converts a #glong value from big-endian to the host byte order.
1006 * Returns: @val converted to host byte order
1011 * @val: a #glong value in little-endian byte order
1013 * Converts a #glong value from little-endian to host byte order.
1015 * Returns: @val converted to host byte order
1020 * @val: a #glong value in host byte order
1022 * Converts a #glong value from host byte order to big-endian.
1024 * Returns: @val converted to big-endian byte order
1029 * @val: a #glong value in host byte order
1031 * Converts a #glong value from host byte order to little-endian.
1033 * Returns: @val converted to little-endian
1038 * @val: a #gulong value in big-endian byte order
1040 * Converts a #gulong value from big-endian to host byte order.
1042 * Returns: @val converted to host byte order
1047 * @val: a #gulong value in little-endian byte order
1049 * Converts a #gulong value from little-endian to host byte order.
1051 * Returns: @val converted to host byte order
1056 * @val: a #gulong value in host byte order
1058 * Converts a #gulong value from host byte order to big-endian.
1060 * Returns: @val converted to big-endian
1065 * @val: a #gulong value in host byte order
1067 * Converts a #gulong value from host byte order to little-endian.
1069 * Returns: @val converted to little-endian
1074 * @val: a #gsize value in big-endian byte order
1076 * Converts a #gsize value from big-endian to the host byte order.
1078 * Returns: @val converted to host byte order
1083 * @val: a #gsize value in little-endian byte order
1085 * Converts a #gsize value from little-endian to host byte order.
1087 * Returns: @val converted to host byte order
1092 * @val: a #gsize value in host byte order
1094 * Converts a #gsize value from host byte order to big-endian.
1096 * Returns: @val converted to big-endian byte order
1101 * @val: a #gsize value in host byte order
1103 * Converts a #gsize value from host byte order to little-endian.
1105 * Returns: @val converted to little-endian
1110 * @val: a #gssize value in big-endian byte order
1112 * Converts a #gssize value from big-endian to host byte order.
1114 * Returns: @val converted to host byte order
1119 * @val: a #gssize value in little-endian byte order
1121 * Converts a #gssize value from little-endian to host byte order.
1123 * Returns: @val converted to host byte order
1128 * @val: a #gssize value in host byte order
1130 * Converts a #gssize value from host byte order to big-endian.
1132 * Returns: @val converted to big-endian
1137 * @val: a #gssize value in host byte order
1139 * Converts a #gssize value from host byte order to little-endian.
1141 * Returns: @val converted to little-endian
1146 * @val: a #gint16 value in big-endian byte order
1148 * Converts a #gint16 value from big-endian to host byte order.
1150 * Returns: @val converted to host byte order
1155 * @val: a #gint16 value in little-endian byte order
1157 * Converts a #gint16 value from little-endian to host byte order.
1159 * Returns: @val converted to host byte order
1164 * @val: a #gint16 value in host byte order
1166 * Converts a #gint16 value from host byte order to big-endian.
1168 * Returns: @val converted to big-endian
1173 * @val: a #gint16 value in host byte order
1175 * Converts a #gint16 value from host byte order to little-endian.
1177 * Returns: @val converted to little-endian
1182 * @val: a #guint16 value in big-endian byte order
1184 * Converts a #guint16 value from big-endian to host byte order.
1186 * Returns: @val converted to host byte order
1191 * @val: a #guint16 value in little-endian byte order
1193 * Converts a #guint16 value from little-endian to host byte order.
1195 * Returns: @val converted to host byte order
1200 * @val: a #guint16 value in host byte order
1202 * Converts a #guint16 value from host byte order to big-endian.
1204 * Returns: @val converted to big-endian
1209 * @val: a #guint16 value in host byte order
1211 * Converts a #guint16 value from host byte order to little-endian.
1213 * Returns: @val converted to little-endian
1218 * @val: a #gint32 value in big-endian byte order
1220 * Converts a #gint32 value from big-endian to host byte order.
1222 * Returns: @val converted to host byte order
1227 * @val: a #gint32 value in little-endian byte order
1229 * Converts a #gint32 value from little-endian to host byte order.
1231 * Returns: @val converted to host byte order
1236 * @val: a #gint32 value in host byte order
1238 * Converts a #gint32 value from host byte order to big-endian.
1240 * Returns: @val converted to big-endian
1245 * @val: a #gint32 value in host byte order
1247 * Converts a #gint32 value from host byte order to little-endian.
1249 * Returns: @val converted to little-endian
1254 * @val: a #guint32 value in big-endian byte order
1256 * Converts a #guint32 value from big-endian to host byte order.
1258 * Returns: @val converted to host byte order
1263 * @val: a #guint32 value in little-endian byte order
1265 * Converts a #guint32 value from little-endian to host byte order.
1267 * Returns: @val converted to host byte order
1272 * @val: a #guint32 value in host byte order
1274 * Converts a #guint32 value from host byte order to big-endian.
1276 * Returns: @val converted to big-endian
1281 * @val: a #guint32 value in host byte order
1283 * Converts a #guint32 value from host byte order to little-endian.
1285 * Returns: @val converted to little-endian
1290 * @val: a #gint64 value in big-endian byte order
1292 * Converts a #gint64 value from big-endian to host byte order.
1294 * Returns: @val converted to host byte order
1299 * @val: a #gint64 value in little-endian byte order
1301 * Converts a #gint64 value from little-endian to host byte order.
1303 * Returns: @val converted to host byte order
1308 * @val: a #gint64 value in host byte order
1310 * Converts a #gint64 value from host byte order to big-endian.
1312 * Returns: @val converted to big-endian
1317 * @val: a #gint64 value in host byte order
1319 * Converts a #gint64 value from host byte order to little-endian.
1321 * Returns: @val converted to little-endian
1326 * @val: a #guint64 value in big-endian byte order
1328 * Converts a #guint64 value from big-endian to host byte order.
1330 * Returns: @val converted to host byte order
1335 * @val: a #guint64 value in little-endian byte order
1337 * Converts a #guint64 value from little-endian to host byte order.
1339 * Returns: @val converted to host byte order
1344 * @val: a #guint64 value in host byte order
1346 * Converts a #guint64 value from host byte order to big-endian.
1348 * Returns: @val converted to big-endian
1353 * @val: a #guint64 value in host byte order
1355 * Converts a #guint64 value from host byte order to little-endian.
1357 * Returns: @val converted to little-endian
1361 * GUINT16_SWAP_BE_PDP:
1362 * @val: a #guint16 value in big-endian or pdp-endian byte order
1364 * Converts a #guint16 value between big-endian and pdp-endian byte order.
1365 * The conversion is symmetric so it can be used both ways.
1367 * Returns: @val converted to the opposite byte order
1371 * GUINT16_SWAP_LE_BE:
1372 * @val: a #guint16 value in little-endian or big-endian byte order
1374 * Converts a #guint16 value between little-endian and big-endian byte order.
1375 * The conversion is symmetric so it can be used both ways.
1377 * Returns: @val converted to the opposite byte order
1381 * GUINT16_SWAP_LE_PDP:
1382 * @val: a #guint16 value in little-endian or pdp-endian byte order
1384 * Converts a #guint16 value between little-endian and pdp-endian byte order.
1385 * The conversion is symmetric so it can be used both ways.
1387 * Returns: @val converted to the opposite byte order
1391 * GUINT32_SWAP_BE_PDP:
1392 * @val: a #guint32 value in big-endian or pdp-endian byte order
1394 * Converts a #guint32 value between big-endian and pdp-endian byte order.
1395 * The conversion is symmetric so it can be used both ways.
1397 * Returns: @val converted to the opposite byte order
1401 * GUINT32_SWAP_LE_BE:
1402 * @val: a #guint32 value in little-endian or big-endian byte order
1404 * Converts a #guint32 value between little-endian and big-endian byte order.
1405 * The conversion is symmetric so it can be used both ways.
1407 * Returns: @val converted to the opposite byte order
1411 * GUINT32_SWAP_LE_PDP:
1412 * @val: a #guint32 value in little-endian or pdp-endian byte order
1414 * Converts a #guint32 value between little-endian and pdp-endian byte order.
1415 * The conversion is symmetric so it can be used both ways.
1417 * Returns: @val converted to the opposite byte order
1421 * GUINT64_SWAP_LE_BE:
1422 * @val: a #guint64 value in little-endian or big-endian byte order
1424 * Converts a #guint64 value between little-endian and big-endian byte order.
1425 * The conversion is symmetric so it can be used both ways.
1427 * Returns: @val converted to the opposite byte order
1430 /* Bounds-checked integer arithmetic {{{1 */
1432 * SECTION:checkedmath
1433 * @title: Bounds-checking integer arithmetic
1434 * @short_description: a set of helpers for performing checked integer arithmetic
1436 * GLib offers a set of macros for doing additions and multiplications
1437 * of unsigned integers, with checks for overflows.
1439 * The helpers all have three arguments. A pointer to the destination
1440 * is always the first argument and the operands to the operation are
1443 * Following standard GLib convention, the helpers return %TRUE in case
1444 * of success (ie: no overflow).
1446 * The helpers may be macros, normal functions or inlines. They may be
1447 * implemented with inline assembly or compiler intrinsics where
1454 * g_uint_checked_add
1455 * @dest: a pointer to the #guint destination
1456 * @a: the #guint left operand
1457 * @b: the #guint right operand
1459 * Performs a checked addition of @a and @b, storing the result in
1462 * If the operation is successful, %TRUE is returned. If the operation
1463 * overflows then the state of @dest is undefined and %FALSE is
1466 * Returns: %TRUE if there was no overflow
1471 * g_uint_checked_mul
1472 * @dest: a pointer to the #guint destination
1473 * @a: the #guint left operand
1474 * @b: the #guint right operand
1476 * Performs a checked multiplication of @a and @b, storing the result in
1479 * If the operation is successful, %TRUE is returned. If the operation
1480 * overflows then the state of @dest is undefined and %FALSE is
1483 * Returns: %TRUE if there was no overflow
1488 * g_uint64_checked_add
1489 * @dest: a pointer to the #guint64 destination
1490 * @a: the #guint64 left operand
1491 * @b: the #guint64 right operand
1493 * Performs a checked addition of @a and @b, storing the result in
1496 * If the operation is successful, %TRUE is returned. If the operation
1497 * overflows then the state of @dest is undefined and %FALSE is
1500 * Returns: %TRUE if there was no overflow
1505 * g_uint64_checked_mul
1506 * @dest: a pointer to the #guint64 destination
1507 * @a: the #guint64 left operand
1508 * @b: the #guint64 right operand
1510 * Performs a checked multiplication of @a and @b, storing the result in
1513 * If the operation is successful, %TRUE is returned. If the operation
1514 * overflows then the state of @dest is undefined and %FALSE is
1517 * Returns: %TRUE if there was no overflow
1522 * g_size_checked_add
1523 * @dest: a pointer to the #gsize destination
1524 * @a: the #gsize left operand
1525 * @b: the #gsize right operand
1527 * Performs a checked addition of @a and @b, storing the result in
1530 * If the operation is successful, %TRUE is returned. If the operation
1531 * overflows then the state of @dest is undefined and %FALSE is
1534 * Returns: %TRUE if there was no overflow
1539 * g_size_checked_mul
1540 * @dest: a pointer to the #gsize destination
1541 * @a: the #gsize left operand
1542 * @b: the #gsize right operand
1544 * Performs a checked multiplication of @a and @b, storing the result in
1547 * If the operation is successful, %TRUE is returned. If the operation
1548 * overflows then the state of @dest is undefined and %FALSE is
1551 * Returns: %TRUE if there was no overflow
1554 /* Numerical Definitions {{{1 */
1558 * @title: Numerical Definitions
1559 * @short_description: mathematical constants, and floating point decomposition
1561 * GLib offers mathematical constants such as #G_PI for the value of pi;
1562 * many platforms have these in the C library, but some don't, the GLib
1563 * versions always exist.
1565 * The #GFloatIEEE754 and #GDoubleIEEE754 unions are used to access the
1566 * sign, mantissa and exponent of IEEE floats and doubles. These unions are
1567 * defined as appropriate for a given platform. IEEE floats and doubles are
1568 * supported (used for storage) by at least Intel, PPC and Sparc. See
1569 * [IEEE 754-2008](http://en.wikipedia.org/wiki/IEEE_float)
1570 * for more information about IEEE number formats.
1574 * G_IEEE754_FLOAT_BIAS:
1576 * The bias by which exponents in single-precision floats are offset.
1580 * G_IEEE754_DOUBLE_BIAS:
1582 * The bias by which exponents in double-precision floats are offset.
1587 * @v_float: the double value
1589 * The #GFloatIEEE754 and #GDoubleIEEE754 unions are used to access the sign,
1590 * mantissa and exponent of IEEE floats and doubles. These unions are defined
1591 * as appropriate for a given platform. IEEE floats and doubles are supported
1592 * (used for storage) by at least Intel, PPC and Sparc.
1597 * @v_double: the double value
1599 * The #GFloatIEEE754 and #GDoubleIEEE754 unions are used to access the sign,
1600 * mantissa and exponent of IEEE floats and doubles. These unions are defined
1601 * as appropriate for a given platform. IEEE floats and doubles are supported
1602 * (used for storage) by at least Intel, PPC and Sparc.
1608 * The base of natural logarithms.
1614 * The natural logarithm of 2.
1620 * The natural logarithm of 10.
1626 * The value of pi (ratio of circle's circumference to its diameter).
1644 * The square root of two.
1650 * Multiplying the base 2 exponent by this number yields the base 10 exponent.
1657 * @title: Standard Macros
1658 * @short_description: commonly-used macros
1660 * These macros provide a few commonly-used features.
1666 * This macro is defined only on Windows. So you can bracket
1667 * Windows-specific code in "\#ifdef G_OS_WIN32".
1673 * This macro is defined only on UNIX. So you can bracket
1674 * UNIX-specific code in "\#ifdef G_OS_UNIX".
1680 * The directory separator character.
1681 * This is '/' on UNIX machines and '\' under Windows.
1685 * G_DIR_SEPARATOR_S:
1687 * The directory separator as a string.
1688 * This is "/" on UNIX machines and "\" under Windows.
1692 * G_IS_DIR_SEPARATOR:
1695 * Checks whether a character is a directory
1696 * separator. It returns %TRUE for '/' on UNIX
1697 * machines and for '\' or '/' under Windows.
1703 * G_SEARCHPATH_SEPARATOR:
1705 * The search path separator character.
1706 * This is ':' on UNIX machines and ';' under Windows.
1710 * G_SEARCHPATH_SEPARATOR_S:
1712 * The search path separator as a string.
1713 * This is ":" on UNIX machines and ";" under Windows.
1719 * Defines the %TRUE value for the #gboolean type.
1725 * Defines the %FALSE value for the #gboolean type.
1731 * Defines the standard %NULL pointer.
1736 * @a: a numeric value
1737 * @b: a numeric value
1739 * Calculates the minimum of @a and @b.
1741 * Returns: the minimum of @a and @b.
1746 * @a: a numeric value
1747 * @b: a numeric value
1749 * Calculates the maximum of @a and @b.
1751 * Returns: the maximum of @a and @b.
1756 * @a: a numeric value
1758 * Calculates the absolute value of @a.
1759 * The absolute value is simply the number with any negative sign taken away.
1763 * - ABS(10) is also 10.
1765 * Returns: the absolute value of @a.
1770 * @x: the value to clamp
1771 * @low: the minimum value allowed
1772 * @high: the maximum value allowed
1774 * Ensures that @x is between the limits set by @low and @high. If @low is
1775 * greater than @high the result is undefined.
1778 * - CLAMP(5, 10, 15) is 10.
1779 * - CLAMP(15, 5, 10) is 10.
1780 * - CLAMP(20, 15, 25) is 20.
1782 * Returns: the value of @x clamped to the range between @low and @high
1787 * @member_type: the type of the struct field
1788 * @struct_p: a pointer to a struct
1789 * @struct_offset: the offset of the field from the start of the struct,
1792 * Returns a member of a structure at a given offset, using the given type.
1794 * Returns: the struct member
1798 * G_STRUCT_MEMBER_P:
1799 * @struct_p: a pointer to a struct
1800 * @struct_offset: the offset from the start of the struct, in bytes
1802 * Returns an untyped pointer to a given offset of a struct.
1804 * Returns: an untyped pointer to @struct_p plus @struct_offset bytes
1809 * @struct_type: a structure type, e.g. #GtkWidget
1810 * @member: a field in the structure, e.g. @window
1812 * Returns the offset, in bytes, of a member of a struct.
1814 * Returns: the offset of @member from the start of @struct_type
1820 * If %G_DISABLE_CONST_RETURNS is defined, this macro expands
1821 * to nothing. By default, the macro expands to const. The macro
1822 * can be used in place of const for functions that return a value
1823 * that should not be modified. The purpose of this macro is to allow
1824 * us to turn on const for returned constant strings by default, while
1825 * allowing programmers who find that annoying to turn it off. This macro
1826 * should only be used for return values and for "out" parameters, it
1827 * doesn't make sense for "in" parameters.
1829 * Deprecated: 2.30: API providers should replace all existing uses with
1830 * const and API consumers should adjust their code accordingly
1837 * Determines the number of elements in an array. The array must be
1838 * declared so the compiler knows its size at compile-time; this
1839 * macro will not work on an array allocated on the heap, only static
1840 * arrays or arrays on the stack.
1843 /* Miscellaneous Macros {{{1 */
1846 * SECTION:macros_misc
1847 * @title: Miscellaneous Macros
1848 * @short_description: specialized macros which are not used often
1850 * These macros provide more specialized features which are not
1851 * needed so often by application programmers.
1857 * This macro used to be used to conditionally define inline functions
1858 * in a compatible way before this feature was supported in all
1859 * compilers. These days, GLib requires inlining support from the
1860 * compiler, so your GLib-using programs can safely assume that the
1861 * "inline" keywork works properly.
1863 * Never use this macro anymore. Just say "static inline".
1865 * Deprecated: 2.48: Use "static inline" instead
1871 * Used within multi-statement macros so that they can be used in places
1872 * where only one statement is expected by the compiler.
1878 * Used within multi-statement macros so that they can be used in places
1879 * where only one statement is expected by the compiler.
1885 * Used (along with #G_END_DECLS) to bracket header files. If the
1886 * compiler in use is a C++ compiler, adds extern "C"
1887 * around the header.
1893 * Used (along with #G_BEGIN_DECLS) to bracket header files. If the
1894 * compiler in use is a C++ compiler, adds extern "C"
1895 * around the header.
1900 * @ap1: the va_list variable to place a copy of @ap2 in
1903 * Portable way to copy va_list variables.
1905 * In order to use this function, you must include string.h yourself,
1906 * because this macro may use memmove() and GLib does not include
1912 * @macro_or_string: a macro or a string
1914 * Accepts a macro or a string and converts it into a string after
1915 * preprocessor argument expansion. For example, the following code:
1917 * |[<!-- language="C" -->
1919 * const gchar *greeting = G_STRINGIFY (AGE) " today!";
1922 * is transformed by the preprocessor into (code equivalent to):
1924 * |[<!-- language="C" -->
1925 * const gchar *greeting = "27 today!";
1931 * @identifier1: an identifier
1932 * @identifier2: an identifier
1934 * Yields a new preprocessor pasted identifier
1935 * @identifier1identifier2 from its expanded
1936 * arguments @identifier1 and @identifier2. For example,
1937 * the following code:
1938 * |[<!-- language="C" -->
1939 * #define GET(traveller,method) G_PASTE(traveller_get_, method) (traveller)
1940 * const gchar *name = GET (traveller, name);
1941 * const gchar *quest = GET (traveller, quest);
1942 * GdkColor *favourite = GET (traveller, favourite_colour);
1945 * is transformed by the preprocessor into:
1946 * |[<!-- language="C" -->
1947 * const gchar *name = traveller_get_name (traveller);
1948 * const gchar *quest = traveller_get_quest (traveller);
1949 * GdkColor *favourite = traveller_get_favourite_colour (traveller);
1957 * @expr: a constant expression
1959 * The G_STATIC_ASSERT() macro lets the programmer check
1960 * a condition at compile time, the condition needs to
1961 * be compile time computable. The macro can be used in
1962 * any place where a typedef is valid.
1964 * A typedef is generally allowed in exactly the same places that
1965 * a variable declaration is allowed. For this reason, you should
1966 * not use G_STATIC_ASSERT() in the middle of blocks of code.
1968 * The macro should only be used once per source code line.
1974 * G_STATIC_ASSERT_EXPR:
1975 * @expr: a constant expression
1977 * The G_STATIC_ASSERT_EXPR() macro lets the programmer check
1978 * a condition at compile time. The condition needs to be
1979 * compile time computable.
1981 * Unlike G_STATIC_ASSERT(), this macro evaluates to an expression
1982 * and, as such, can be used in the middle of other expressions.
1983 * Its value should be ignored. This can be accomplished by placing
1984 * it as the first argument of a comma expression.
1986 * |[<!-- language="C" -->
1987 * #define ADD_ONE_TO_INT(x) \
1988 * (G_STATIC_ASSERT_EXPR(sizeof (x) == sizeof (int)), ((x) + 1))
1997 * Expands to __extension__ when gcc is used as the compiler. This simply
1998 * tells gcc not to warn about the following non-standard code when compiling
1999 * with the `-pedantic` option.
2003 * G_GNUC_CHECK_VERSION:
2004 * @major: major version to check against
2005 * @minor: minor version to check against
2007 * Expands to a a check for a compiler with __GNUC__ defined and a version
2008 * greater than or equal to the major and minor numbers provided. For example,
2009 * the following would only match on compilers such as GCC 4.8 or newer.
2011 * |[<!-- language="C" -->
2012 * #if G_GNUC_CHECK_VERSION(4, 8)
2022 * Expands to the GNU C const function attribute if the compiler is gcc.
2023 * Declaring a function as const enables better optimization of calls to
2024 * the function. A const function doesn't examine any values except its
2025 * parameters, and has no effects except its return value.
2027 * Place the attribute after the declaration, just before the semicolon.
2029 * See the GNU C documentation for more details.
2031 * A function that has pointer arguments and examines the data pointed to
2032 * must not be declared const. Likewise, a function that calls a non-const
2033 * function usually must not be const. It doesn't make sense for a const
2034 * function to return void.
2040 * Expands to the GNU C pure function attribute if the compiler is gcc.
2041 * Declaring a function as pure enables better optimization of calls to
2042 * the function. A pure function has no effects except its return value
2043 * and the return value depends only on the parameters and/or global
2046 * Place the attribute after the declaration, just before the semicolon.
2048 * See the GNU C documentation for more details.
2054 * Expands to the GNU C malloc function attribute if the compiler is gcc.
2055 * Declaring a function as malloc enables better optimization of the function.
2056 * A function can have the malloc attribute if it returns a pointer which is
2057 * guaranteed to not alias with any other pointer when the function returns
2058 * (in practice, this means newly allocated memory).
2060 * Place the attribute after the declaration, just before the semicolon.
2062 * See the GNU C documentation for more details.
2068 * G_GNUC_ALLOC_SIZE:
2069 * @x: the index of the argument specifying the allocation size
2071 * Expands to the GNU C alloc_size function attribute if the compiler
2072 * is a new enough gcc. This attribute tells the compiler that the
2073 * function returns a pointer to memory of a size that is specified
2074 * by the @xth function parameter.
2076 * Place the attribute after the function declaration, just before the
2079 * See the GNU C documentation for more details.
2085 * G_GNUC_ALLOC_SIZE2:
2086 * @x: the index of the argument specifying one factor of the allocation size
2087 * @y: the index of the argument specifying the second factor of the allocation size
2089 * Expands to the GNU C alloc_size function attribute if the compiler is a
2090 * new enough gcc. This attribute tells the compiler that the function returns
2091 * a pointer to memory of a size that is specified by the product of two
2092 * function parameters.
2094 * Place the attribute after the function declaration, just before the
2097 * See the GNU C documentation for more details.
2103 * G_GNUC_DEPRECATED:
2105 * Expands to the GNU C deprecated attribute if the compiler is gcc.
2106 * It can be used to mark typedefs, variables and functions as deprecated.
2107 * When called with the `-Wdeprecated-declarations` option,
2108 * gcc will generate warnings when deprecated interfaces are used.
2110 * Place the attribute after the declaration, just before the semicolon.
2112 * See the GNU C documentation for more details.
2118 * G_GNUC_DEPRECATED_FOR:
2119 * @f: the intended replacement for the deprecated symbol,
2120 * such as the name of a function
2122 * Like %G_GNUC_DEPRECATED, but names the intended replacement for the
2123 * deprecated symbol if the version of gcc in use is new enough to support
2124 * custom deprecation messages.
2126 * Place the attribute after the declaration, just before the semicolon.
2128 * See the GNU C documentation for more details.
2130 * Note that if @f is a macro, it will be expanded in the warning message.
2131 * You can enclose it in quotes to prevent this. (The quotes will show up
2132 * in the warning, but it's better than showing the macro expansion.)
2138 * G_GNUC_BEGIN_IGNORE_DEPRECATIONS:
2140 * Tells gcc (if it is a new enough version) to temporarily stop emitting
2141 * warnings when functions marked with %G_GNUC_DEPRECATED or
2142 * %G_GNUC_DEPRECATED_FOR are called. This is useful for when you have
2143 * one deprecated function calling another one, or when you still have
2144 * regression tests for deprecated functions.
2146 * Use %G_GNUC_END_IGNORE_DEPRECATIONS to begin warning again. (If you
2147 * are not compiling with `-Wdeprecated-declarations` then neither macro
2150 * This macro can be used either inside or outside of a function body,
2151 * but must appear on a line by itself.
2157 * G_GNUC_END_IGNORE_DEPRECATIONS:
2159 * Undoes the effect of %G_GNUC_BEGIN_IGNORE_DEPRECATIONS, telling
2160 * gcc to begin outputting warnings again (assuming those warnings
2161 * had been enabled to begin with).
2163 * This macro can be used either inside or outside of a function body,
2164 * but must appear on a line by itself.
2172 * This macro is similar to %G_GNUC_DEPRECATED, and can be used to mark
2173 * functions declarations as deprecated. Unlike %G_GNUC_DEPRECATED, it is
2174 * meant to be portable across different compilers and must be placed
2175 * before the function declaration.
2182 * @f: the name of the function that this function was deprecated for
2184 * This macro is similar to %G_GNUC_DEPRECATED_FOR, and can be used to mark
2185 * functions declarations as deprecated. Unlike %G_GNUC_DEPRECATED_FOR, it
2186 * is meant to be portable across different compilers and must be placed
2187 * before the function declaration.
2194 * @maj: the major version that introduced the symbol
2195 * @min: the minor version that introduced the symbol
2197 * This macro can be used to mark a function declaration as unavailable.
2198 * It must be placed before the function declaration. Use of a function
2199 * that has been annotated with this macros will produce a compiler warning.
2205 * GLIB_DISABLE_DEPRECATION_WARNINGS:
2207 * A macro that should be defined before including the glib.h header.
2208 * If it is defined, no compiler warnings will be produced for uses
2209 * of deprecated GLib APIs.
2215 * Expands to the GNU C noreturn function attribute if the compiler is gcc.
2216 * It is used for declaring functions which never return. It enables
2217 * optimization of the function, and avoids possible compiler warnings.
2219 * Place the attribute after the declaration, just before the semicolon.
2221 * See the GNU C documentation for more details.
2227 * Expands to the GNU C unused function attribute if the compiler is gcc.
2228 * It is used for declaring functions and arguments which may never be used.
2229 * It avoids possible compiler warnings.
2231 * For functions, place the attribute after the declaration, just before the
2232 * semicolon. For arguments, place the attribute at the beginning of the
2233 * argument declaration.
2235 * |[<!-- language="C" -->
2236 * void my_unused_function (G_GNUC_UNUSED gint unused_argument,
2237 * gint other_argument) G_GNUC_UNUSED;
2240 * See the GNU C documentation for more details.
2245 * @format_idx: the index of the argument corresponding to the
2246 * format string (the arguments are numbered from 1)
2247 * @arg_idx: the index of the first of the format arguments, or 0 if
2248 * there are no format arguments
2250 * Expands to the GNU C format function attribute if the compiler is gcc.
2251 * This is used for declaring functions which take a variable number of
2252 * arguments, with the same syntax as printf(). It allows the compiler
2253 * to type-check the arguments passed to the function.
2255 * Place the attribute after the function declaration, just before the
2259 * [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-Wformat-3288)
2262 * |[<!-- language="C" -->
2263 * gint g_snprintf (gchar *string,
2265 * gchar const *format,
2266 * ...) G_GNUC_PRINTF (3, 4);
2272 * @format_idx: the index of the argument corresponding to
2273 * the format string (the arguments are numbered from 1)
2274 * @arg_idx: the index of the first of the format arguments, or 0 if
2275 * there are no format arguments
2277 * Expands to the GNU C format function attribute if the compiler is gcc.
2278 * This is used for declaring functions which take a variable number of
2279 * arguments, with the same syntax as scanf(). It allows the compiler
2280 * to type-check the arguments passed to the function.
2283 * [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-Wformat-3288)
2289 * @arg_idx: the index of the argument
2291 * Expands to the GNU C format_arg function attribute if the compiler
2292 * is gcc. This function attribute specifies that a function takes a
2293 * format string for a printf(), scanf(), strftime() or strfmon() style
2294 * function and modifies it, so that the result can be passed to a printf(),
2295 * scanf(), strftime() or strfmon() style function (with the remaining
2296 * arguments to the format function the same as they would have been
2297 * for the unmodified string).
2299 * Place the attribute after the function declaration, just before the
2302 * See the GNU C documentation for more details.
2304 * |[<!-- language="C" -->
2305 * gchar *g_dgettext (gchar *domain_name, gchar *msgid) G_GNUC_FORMAT (2);
2310 * G_GNUC_NULL_TERMINATED:
2312 * Expands to the GNU C sentinel function attribute if the compiler is gcc.
2313 * This function attribute only applies to variadic functions and instructs
2314 * the compiler to check that the argument list is terminated with an
2317 * Place the attribute after the declaration, just before the semicolon.
2319 * See the GNU C documentation for more details.
2325 * G_GNUC_WARN_UNUSED_RESULT:
2327 * Expands to the GNU C warn_unused_result function attribute if the compiler
2328 * is gcc. This function attribute makes the compiler emit a warning if the
2329 * result of a function call is ignored.
2331 * Place the attribute after the declaration, just before the semicolon.
2333 * See the GNU C documentation for more details.
2341 * Expands to "" on all modern compilers, and to __FUNCTION__ on gcc
2342 * version 2.x. Don't use it.
2344 * Deprecated: 2.16: Use G_STRFUNC() instead
2348 * G_GNUC_PRETTY_FUNCTION:
2350 * Expands to "" on all modern compilers, and to __PRETTY_FUNCTION__
2351 * on gcc version 2.x. Don't use it.
2353 * Deprecated: 2.16: Use G_STRFUNC() instead
2357 * G_GNUC_NO_INSTRUMENT:
2359 * Expands to the GNU C no_instrument_function function attribute if the
2360 * compiler is gcc. Functions with this attribute will not be instrumented
2361 * for profiling, when the compiler is called with the
2362 * `-finstrument-functions` option.
2364 * Place the attribute after the declaration, just before the semicolon.
2366 * See the GNU C documentation for more details.
2372 * This attribute can be used for marking library functions as being used
2373 * internally to the library only, which may allow the compiler to handle
2374 * function calls more efficiently. Note that static functions do not need
2375 * to be marked as internal in this way. See the GNU C documentation for
2378 * When using a compiler that supports the GNU C hidden visibility attribute,
2379 * this macro expands to __attribute__((visibility("hidden"))).
2380 * When using the Sun Studio compiler, it expands to __hidden.
2382 * Note that for portability, the attribute should be placed before the
2383 * function declaration. While GCC allows the macro after the declaration,
2384 * Sun Studio does not.
2386 * |[<!-- language="C" -->
2388 * void _g_log_fallback_handler (const gchar *log_domain,
2389 * GLogLevelFlags log_level,
2390 * const gchar *message,
2391 * gpointer unused_data);
2400 * Expands to the GNU C may_alias type attribute if the compiler is gcc.
2401 * Types with this attribute will not be subjected to type-based alias
2402 * analysis, but are assumed to alias with any other type, just like char.
2404 * See the GNU C documentation for details.
2411 * @expr: the expression
2413 * Hints the compiler that the expression is likely to evaluate to
2414 * a true value. The compiler may use this information for optimizations.
2416 * |[<!-- language="C" -->
2417 * if (G_LIKELY (random () != 1))
2418 * g_print ("not one");
2421 * Returns: the value of @expr
2428 * @expr: the expression
2430 * Hints the compiler that the expression is unlikely to evaluate to
2431 * a true value. The compiler may use this information for optimizations.
2433 * |[<!-- language="C" -->
2434 * if (G_UNLIKELY (random () == 1))
2435 * g_print ("a random one");
2438 * Returns: the value of @expr
2446 * Expands to a string identifying the current code position.
2452 * Expands to a string identifying the current function.
2458 * G_HAVE_GNUC_VISIBILITY:
2460 * Defined to 1 if gcc-style visibility handling is supported.
2463 /* g_auto(), g_autoptr() and helpers {{{1 */
2467 * @TypeName: a supported variable type
2469 * Helper to declare a variable with automatic cleanup.
2471 * The variable is cleaned up in a way appropriate to its type when the
2472 * variable goes out of scope. The type must support this.
2474 * This feature is only supported on GCC and clang. This macro is not
2475 * defined on other compilers and should not be used in programs that
2476 * are intended to be portable to those compilers.
2478 * This is meant to be used with stack-allocated structures and
2479 * non-pointer types. For the (more commonly used) pointer version, see
2482 * This macro can be used to avoid having to do explicit cleanups of
2483 * local variables when exiting functions. It often vastly simplifies
2484 * handling of error conditions, removing the need for various tricks
2485 * such as 'goto out' or repeating of cleanup code. It is also helpful
2486 * for non-error cases.
2488 * Consider the following example:
2494 * g_auto(GQueue) queue = G_QUEUE_INIT;
2495 * g_auto(GVariantBuilder) builder;
2496 * g_auto(GStrv) strv;
2498 * g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT);
2499 * strv = g_strsplit("a:b:c", ":", -1);
2503 * if (error_condition)
2508 * return g_variant_builder_end (&builder);
2512 * You must initialize the variable in some way -- either by use of an
2513 * initialiser or by ensuring that an _init function will be called on
2514 * it unconditionally before it goes out of scope.
2521 * @TypeName: a supported variable type
2523 * Helper to declare a pointer variable with automatic cleanup.
2525 * The variable is cleaned up in a way appropriate to its type when the
2526 * variable goes out of scope. The type must support this.
2528 * This feature is only supported on GCC and clang. This macro is not
2529 * defined on other compilers and should not be used in programs that
2530 * are intended to be portable to those compilers.
2532 * This is meant to be used to declare pointers to types with cleanup
2533 * functions. The type of the variable is a pointer to @TypeName. You
2534 * must not add your own '*'.
2536 * This macro can be used to avoid having to do explicit cleanups of
2537 * local variables when exiting functions. It often vastly simplifies
2538 * handling of error conditions, removing the need for various tricks
2539 * such as 'goto out' or repeating of cleanup code. It is also helpful
2540 * for non-error cases.
2542 * Consider the following example:
2546 * check_exists(GVariant *dict)
2548 * g_autoptr(GVariant) dirname, basename = NULL;
2549 * g_autofree gchar *path = NULL;
2551 * dirname = g_variant_lookup_value (dict, "dirname", G_VARIANT_TYPE_STRING);
2553 * if (dirname == NULL)
2556 * basename = g_variant_lookup_value (dict, "basename", G_VARIANT_TYPE_STRING);
2558 * if (basename == NULL)
2561 * path = g_build_filename (g_variant_get_string (dirname, NULL),
2562 * g_variant_get_string (basename, NULL),
2565 * return g_access (path, R_OK) == 0;
2569 * You must initialise the variable in some way -- either by use of an
2570 * initialiser or by ensuring that it is assigned to unconditionally
2571 * before it goes out of scope.
2573 * See also g_auto(), g_autofree() and g_steal_pointer().
2581 * Macro to add an attribute to pointer variable to ensure automatic
2582 * cleanup using g_free().
2584 * This macro differs from g_autoptr() in that it is an attribute supplied
2585 * before the type name, rather than wrapping the type definition. Instead
2586 * of using a type-specific lookup, this macro always calls g_free() directly.
2588 * This means it's useful for any type that is returned from
2591 * Otherwise, this macro has similar constraints as g_autoptr() - only
2592 * supported on GCC and clang, the variable must be initialized, etc.
2596 * operate_on_malloc_buf (void)
2598 * g_autofree guint8* membuf = NULL;
2600 * membuf = g_malloc (8192);
2602 * // Some computation on membuf
2604 * // membuf will be automatically freed here
2614 * @TypeName: a supported variable type
2616 * Helper to declare a list variable with automatic deep cleanup.
2618 * The list is deeply freed, in a way appropriate to the specified type, when the
2619 * variable goes out of scope. The type must support this.
2621 * This feature is only supported on GCC and clang. This macro is not
2622 * defined on other compilers and should not be used in programs that
2623 * are intended to be portable to those compilers.
2625 * This is meant to be used to declare lists of a type with a cleanup
2626 * function. The type of the variable is a GList *. You
2627 * must not add your own '*'.
2629 * This macro can be used to avoid having to do explicit cleanups of
2630 * local variables when exiting functions. It often vastly simplifies
2631 * handling of error conditions, removing the need for various tricks
2632 * such as 'goto out' or repeating of cleanup code. It is also helpful
2633 * for non-error cases.
2635 * See also g_autoslist(), g_autoptr() and g_steal_pointer().
2642 * @TypeName: a supported variable type
2644 * Helper to declare a singly linked list variable with automatic deep cleanup.
2646 * The list is deeply freed, in a way appropriate to the specified type, when the
2647 * variable goes out of scope. The type must support this.
2649 * This feature is only supported on GCC and clang. This macro is not
2650 * defined on other compilers and should not be used in programs that
2651 * are intended to be portable to those compilers.
2653 * This is meant to be used to declare lists of a type with a cleanup
2654 * function. The type of the variable is a GSList *. You
2655 * must not add your own '*'.
2657 * This macro can be used to avoid having to do explicit cleanups of
2658 * local variables when exiting functions. It often vastly simplifies
2659 * handling of error conditions, removing the need for various tricks
2660 * such as 'goto out' or repeating of cleanup code. It is also helpful
2661 * for non-error cases.
2663 * See also g_autolist(), g_autoptr() and g_steal_pointer().
2669 * G_DEFINE_AUTOPTR_CLEANUP_FUNC:
2670 * @TypeName: a type name to define a g_autoptr() cleanup function for
2671 * @func: the cleanup function
2673 * Defines the appropriate cleanup function for a pointer type.
2675 * The function will not be called if the variable to be cleaned up
2678 * This will typically be the _free() or _unref() function for the given
2681 * With this definition, it will be possible to use g_autoptr() with
2685 * G_DEFINE_AUTOPTR_CLEANUP_FUNC(GObject, g_object_unref)
2688 * This macro should be used unconditionally; it is a no-op on compilers
2689 * where cleanup is not supported.
2695 * G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC:
2696 * @TypeName: a type name to define a g_auto() cleanup function for
2697 * @func: the clear function
2699 * Defines the appropriate cleanup function for a type.
2701 * This will typically be the _clear() function for the given type.
2703 * With this definition, it will be possible to use g_auto() with
2707 * G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(GQueue, g_queue_clear)
2710 * This macro should be used unconditionally; it is a no-op on compilers
2711 * where cleanup is not supported.
2717 * G_DEFINE_AUTO_CLEANUP_FREE_FUNC:
2718 * @TypeName: a type name to define a g_auto() cleanup function for
2719 * @func: the free function
2720 * @none: the "none" value for the type
2722 * Defines the appropriate cleanup function for a type.
2724 * With this definition, it will be possible to use g_auto() with
2727 * This function will be rarely used. It is used with pointer-based
2728 * typedefs and non-pointer types where the value of the variable
2729 * represents a resource that must be freed. Two examples are #GStrv
2730 * and file descriptors.
2732 * @none specifies the "none" value for the type in question. It is
2733 * probably something like %NULL or -1. If the variable is found to
2734 * contain this value then the free function will not be called.
2737 * G_DEFINE_AUTO_CLEANUP_FREE_FUNC(GStrv, g_strfreev, NULL)
2740 * This macro should be used unconditionally; it is a no-op on compilers
2741 * where cleanup is not supported.
2746 /* Windows Compatibility Functions {{{1 */
2750 * @title: Windows Compatibility Functions
2751 * @short_description: UNIX emulation on Windows
2753 * These functions provide some level of UNIX emulation on the
2754 * Windows platform. If your application really needs the POSIX
2755 * APIs, we suggest you try the Cygwin project.
2761 * Provided for UNIX emulation on Windows; equivalent to UNIX
2762 * macro %MAXPATHLEN, which is the maximum length of a filename
2763 * (including full path).
2767 * G_WIN32_DLLMAIN_FOR_DLL_NAME:
2768 * @static: empty or "static"
2769 * @dll_name: the name of the (pointer to the) char array where
2770 * the DLL name will be stored. If this is used, you must also
2771 * include `windows.h`. If you need a more complex DLL entry
2772 * point function, you cannot use this
2774 * On Windows, this macro defines a DllMain() function that stores
2775 * the actual DLL name that the code being compiled will be included in.
2777 * On non-Windows platforms, expands to nothing.
2781 * G_WIN32_HAVE_WIDECHAR_API:
2783 * On Windows, this macro defines an expression which evaluates to
2784 * %TRUE if the code is running on a version of Windows where the wide
2785 * character versions of the Win32 API functions, and the wide character
2786 * versions of the C library functions work. (They are always present in
2787 * the DLLs, but don't work on Windows 9x and Me.)
2789 * On non-Windows platforms, it is not defined.
2796 * G_WIN32_IS_NT_BASED:
2798 * On Windows, this macro defines an expression which evaluates to
2799 * %TRUE if the code is running on an NT-based Windows operating system.
2801 * On non-Windows platforms, it is not defined.
2807 /* vim: set foldmethod=marker: */