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 C99 type off64_t.
621 * Values of this type can range from #G_MINOFFSET to
624 * To print or scan values of this type, use
625 * %G_GOFFSET_MODIFIER and/or %G_GOFFSET_FORMAT.
633 * The minimum value which can be held in a #goffset.
639 * The maximum value which can be held in a #goffset.
643 * G_GOFFSET_MODIFIER:
645 * The platform dependent length modifier for conversion specifiers
646 * for scanning and printing values of type #goffset. It is a string
647 * literal. See also #G_GINT64_MODIFIER.
655 * This is the platform dependent conversion specifier for scanning
656 * and printing values of type #goffset. See also #G_GINT64_FORMAT.
662 * G_GOFFSET_CONSTANT:
663 * @val: a literal integer value, e.g. 0x1d636b02300a7aa7
665 * This macro is used to insert #goffset 64-bit integer literals
666 * into the source code.
668 * See also #G_GINT64_CONSTANT.
676 * Corresponds to the C99 type intptr_t,
677 * a signed integer type that can hold any pointer.
679 * To print or scan values of this type, use
680 * %G_GINTPTR_MODIFIER and/or %G_GINTPTR_FORMAT.
686 * G_GINTPTR_MODIFIER:
688 * The platform dependent length modifier for conversion specifiers
689 * for scanning and printing values of type #gintptr or #guintptr.
690 * It is a string literal.
698 * This is the platform dependent conversion specifier for scanning
699 * and printing values of type #gintptr.
707 * Corresponds to the C99 type uintptr_t,
708 * an unsigned integer type that can hold any pointer.
710 * To print or scan values of this type, use
711 * %G_GINTPTR_MODIFIER and/or %G_GUINTPTR_FORMAT.
719 * This is the platform dependent conversion specifier
720 * for scanning and printing values of type #guintptr.
725 /* Type conversion {{{1 */
728 * SECTION:type_conversion
729 * @title: Type Conversion Macros
730 * @short_description: portably storing integers in pointer variables
732 * Many times GLib, GTK+, and other libraries allow you to pass "user
733 * data" to a callback, in the form of a void pointer. From time to time
734 * you want to pass an integer instead of a pointer. You could allocate
735 * an integer, with something like:
736 * |[<!-- language="C" -->
737 * int *ip = g_new (int, 1);
740 * But this is inconvenient, and it's annoying to have to free the
741 * memory at some later time.
743 * Pointers are always at least 32 bits in size (on all platforms GLib
744 * intends to support). Thus you can store at least 32-bit integer values
745 * in a pointer value. Naively, you might try this, but it's incorrect:
746 * |[<!-- language="C" -->
752 * Again, that example was not correct, don't copy it.
753 * The problem is that on some systems you need to do this:
754 * |[<!-- language="C" -->
757 * p = (void*) (long) 42;
758 * i = (int) (long) p;
760 * The GLib macros GPOINTER_TO_INT(), GINT_TO_POINTER(), etc. take care
761 * to do the right thing on the every platform.
763 * Warning: You may not store pointers in integers. This is not
764 * portable in any way, shape or form. These macros only allow storing
765 * integers in pointers, and only preserve 32 bits of the integer; values
766 * outside the range of a 32-bit integer will be mangled.
771 * @i: integer to stuff into a pointer
773 * Stuffs an integer into a pointer type.
775 * Remember, you may not store pointers in integers. This is not portable
776 * in any way, shape or form. These macros only allow storing integers in
777 * pointers, and only preserve 32 bits of the integer; values outside the
778 * range of a 32-bit integer will be mangled.
783 * @p: pointer containing an integer
785 * Extracts an integer from a pointer. The integer must have
786 * been stored in the pointer with GINT_TO_POINTER().
788 * Remember, you may not store pointers in integers. This is not portable
789 * in any way, shape or form. These macros only allow storing integers in
790 * pointers, and only preserve 32 bits of the integer; values outside the
791 * range of a 32-bit integer will be mangled.
796 * @u: unsigned integer to stuff into the pointer
798 * Stuffs an unsigned integer into a pointer type.
803 * @p: pointer to extract an unsigned integer from
805 * Extracts an unsigned integer from a pointer. The integer must have
806 * been stored in the pointer with GUINT_TO_POINTER().
811 * @s: #gsize to stuff into the pointer
813 * Stuffs a #gsize into a pointer type.
818 * @p: pointer to extract a #gsize from
820 * Extracts a #gsize from a pointer. The #gsize must have
821 * been stored in the pointer with GSIZE_TO_POINTER().
824 /* Byte order {{{1 */
828 * @title: Byte Order Macros
829 * @short_description: a portable way to convert between different byte orders
831 * These macros provide a portable way to determine the host byte order
832 * and to convert values between different byte orders.
834 * The byte order is the order in which bytes are stored to create larger
835 * data types such as the #gint and #glong values.
836 * The host byte order is the byte order used on the current machine.
838 * Some processors store the most significant bytes (i.e. the bytes that
839 * hold the largest part of the value) first. These are known as big-endian
840 * processors. Other processors (notably the x86 family) store the most
841 * significant byte last. These are known as little-endian processors.
843 * Finally, to complicate matters, some other processors store the bytes in
844 * a rather curious order known as PDP-endian. For a 4-byte word, the 3rd
845 * most significant byte is stored first, then the 4th, then the 1st and
848 * Obviously there is a problem when these different processors communicate
849 * with each other, for example over networks or by using binary file formats.
850 * This is where these macros come in. They are typically used to convert
851 * values into a byte order which has been agreed on for use when
852 * communicating between different processors. The Internet uses what is
853 * known as 'network byte order' as the standard byte order (which is in
854 * fact the big-endian byte order).
856 * Note that the byte order conversion macros may evaluate their arguments
857 * multiple times, thus you should not use them with arguments which have
864 * The host byte order.
865 * This can be either #G_LITTLE_ENDIAN or #G_BIG_ENDIAN (support for
866 * #G_PDP_ENDIAN may be added in future.)
872 * Specifies one of the possible types of byte order.
879 * Specifies one of the possible types of byte order.
886 * Specifies one of the possible types of byte order
887 * (currently unused). See #G_BYTE_ORDER.
892 * @val: a 32-bit integer value in host byte order
894 * Converts a 32-bit integer value from host to network byte order.
896 * Returns: @val converted to network byte order
901 * @val: a 16-bit integer value in host byte order
903 * Converts a 16-bit integer value from host to network byte order.
905 * Returns: @val converted to network byte order
910 * @val: a 32-bit integer value in network byte order
912 * Converts a 32-bit integer value from network to host byte order.
914 * Returns: @val converted to host byte order.
919 * @val: a 16-bit integer value in network byte order
921 * Converts a 16-bit integer value from network to host byte order.
923 * Returns: @val converted to host byte order
928 * @val: a #gint value in big-endian byte order
930 * Converts a #gint value from big-endian to host byte order.
932 * Returns: @val converted to host byte order
937 * @val: a #gint value in little-endian byte order
939 * Converts a #gint value from little-endian to host byte order.
941 * Returns: @val converted to host byte order
946 * @val: a #gint value in host byte order
948 * Converts a #gint value from host byte order to big-endian.
950 * Returns: @val converted to big-endian byte order
955 * @val: a #gint value in host byte order
957 * Converts a #gint value from host byte order to little-endian.
959 * Returns: @val converted to little-endian byte order
964 * @val: a #guint value in big-endian byte order
966 * Converts a #guint value from big-endian to host byte order.
968 * Returns: @val converted to host byte order
973 * @val: a #guint value in little-endian byte order
975 * Converts a #guint value from little-endian to host byte order.
977 * Returns: @val converted to host byte order
982 * @val: a #guint value in host byte order
984 * Converts a #guint value from host byte order to big-endian.
986 * Returns: @val converted to big-endian byte order
991 * @val: a #guint value in host byte order
993 * Converts a #guint value from host byte order to little-endian.
995 * Returns: @val converted to little-endian byte order.
1000 * @val: a #glong value in big-endian byte order
1002 * Converts a #glong value from big-endian to the host byte order.
1004 * Returns: @val converted to host byte order
1009 * @val: a #glong value in little-endian byte order
1011 * Converts a #glong value from little-endian to host byte order.
1013 * Returns: @val converted to host byte order
1018 * @val: a #glong value in host byte order
1020 * Converts a #glong value from host byte order to big-endian.
1022 * Returns: @val converted to big-endian byte order
1027 * @val: a #glong value in host byte order
1029 * Converts a #glong value from host byte order to little-endian.
1031 * Returns: @val converted to little-endian
1036 * @val: a #gulong value in big-endian byte order
1038 * Converts a #gulong value from big-endian to host byte order.
1040 * Returns: @val converted to host byte order
1045 * @val: a #gulong value in little-endian byte order
1047 * Converts a #gulong value from little-endian to host byte order.
1049 * Returns: @val converted to host byte order
1054 * @val: a #gulong value in host byte order
1056 * Converts a #gulong value from host byte order to big-endian.
1058 * Returns: @val converted to big-endian
1063 * @val: a #gulong value in host byte order
1065 * Converts a #gulong value from host byte order to little-endian.
1067 * Returns: @val converted to little-endian
1072 * @val: a #gsize value in big-endian byte order
1074 * Converts a #gsize value from big-endian to the host byte order.
1076 * Returns: @val converted to host byte order
1081 * @val: a #gsize value in little-endian byte order
1083 * Converts a #gsize value from little-endian to host byte order.
1085 * Returns: @val converted to host byte order
1090 * @val: a #gsize value in host byte order
1092 * Converts a #gsize value from host byte order to big-endian.
1094 * Returns: @val converted to big-endian byte order
1099 * @val: a #gsize value in host byte order
1101 * Converts a #gsize value from host byte order to little-endian.
1103 * Returns: @val converted to little-endian
1108 * @val: a #gssize value in big-endian byte order
1110 * Converts a #gssize value from big-endian to host byte order.
1112 * Returns: @val converted to host byte order
1117 * @val: a #gssize value in little-endian byte order
1119 * Converts a #gssize value from little-endian to host byte order.
1121 * Returns: @val converted to host byte order
1126 * @val: a #gssize value in host byte order
1128 * Converts a #gssize value from host byte order to big-endian.
1130 * Returns: @val converted to big-endian
1135 * @val: a #gssize value in host byte order
1137 * Converts a #gssize value from host byte order to little-endian.
1139 * Returns: @val converted to little-endian
1144 * @val: a #gint16 value in big-endian byte order
1146 * Converts a #gint16 value from big-endian to host byte order.
1148 * Returns: @val converted to host byte order
1153 * @val: a #gint16 value in little-endian byte order
1155 * Converts a #gint16 value from little-endian to host byte order.
1157 * Returns: @val converted to host byte order
1162 * @val: a #gint16 value in host byte order
1164 * Converts a #gint16 value from host byte order to big-endian.
1166 * Returns: @val converted to big-endian
1171 * @val: a #gint16 value in host byte order
1173 * Converts a #gint16 value from host byte order to little-endian.
1175 * Returns: @val converted to little-endian
1180 * @val: a #guint16 value in big-endian byte order
1182 * Converts a #guint16 value from big-endian to host byte order.
1184 * Returns: @val converted to host byte order
1189 * @val: a #guint16 value in little-endian byte order
1191 * Converts a #guint16 value from little-endian to host byte order.
1193 * Returns: @val converted to host byte order
1198 * @val: a #guint16 value in host byte order
1200 * Converts a #guint16 value from host byte order to big-endian.
1202 * Returns: @val converted to big-endian
1207 * @val: a #guint16 value in host byte order
1209 * Converts a #guint16 value from host byte order to little-endian.
1211 * Returns: @val converted to little-endian
1216 * @val: a #gint32 value in big-endian byte order
1218 * Converts a #gint32 value from big-endian to host byte order.
1220 * Returns: @val converted to host byte order
1225 * @val: a #gint32 value in little-endian byte order
1227 * Converts a #gint32 value from little-endian to host byte order.
1229 * Returns: @val converted to host byte order
1234 * @val: a #gint32 value in host byte order
1236 * Converts a #gint32 value from host byte order to big-endian.
1238 * Returns: @val converted to big-endian
1243 * @val: a #gint32 value in host byte order
1245 * Converts a #gint32 value from host byte order to little-endian.
1247 * Returns: @val converted to little-endian
1252 * @val: a #guint32 value in big-endian byte order
1254 * Converts a #guint32 value from big-endian to host byte order.
1256 * Returns: @val converted to host byte order
1261 * @val: a #guint32 value in little-endian byte order
1263 * Converts a #guint32 value from little-endian to host byte order.
1265 * Returns: @val converted to host byte order
1270 * @val: a #guint32 value in host byte order
1272 * Converts a #guint32 value from host byte order to big-endian.
1274 * Returns: @val converted to big-endian
1279 * @val: a #guint32 value in host byte order
1281 * Converts a #guint32 value from host byte order to little-endian.
1283 * Returns: @val converted to little-endian
1288 * @val: a #gint64 value in big-endian byte order
1290 * Converts a #gint64 value from big-endian to host byte order.
1292 * Returns: @val converted to host byte order
1297 * @val: a #gint64 value in little-endian byte order
1299 * Converts a #gint64 value from little-endian to host byte order.
1301 * Returns: @val converted to host byte order
1306 * @val: a #gint64 value in host byte order
1308 * Converts a #gint64 value from host byte order to big-endian.
1310 * Returns: @val converted to big-endian
1315 * @val: a #gint64 value in host byte order
1317 * Converts a #gint64 value from host byte order to little-endian.
1319 * Returns: @val converted to little-endian
1324 * @val: a #guint64 value in big-endian byte order
1326 * Converts a #guint64 value from big-endian to host byte order.
1328 * Returns: @val converted to host byte order
1333 * @val: a #guint64 value in little-endian byte order
1335 * Converts a #guint64 value from little-endian to host byte order.
1337 * Returns: @val converted to host byte order
1342 * @val: a #guint64 value in host byte order
1344 * Converts a #guint64 value from host byte order to big-endian.
1346 * Returns: @val converted to big-endian
1351 * @val: a #guint64 value in host byte order
1353 * Converts a #guint64 value from host byte order to little-endian.
1355 * Returns: @val converted to little-endian
1359 * GUINT16_SWAP_BE_PDP:
1360 * @val: a #guint16 value in big-endian or pdp-endian byte order
1362 * Converts a #guint16 value between big-endian and pdp-endian byte order.
1363 * The conversion is symmetric so it can be used both ways.
1365 * Returns: @val converted to the opposite byte order
1369 * GUINT16_SWAP_LE_BE:
1370 * @val: a #guint16 value in little-endian or big-endian byte order
1372 * Converts a #guint16 value between little-endian and big-endian byte order.
1373 * The conversion is symmetric so it can be used both ways.
1375 * Returns: @val converted to the opposite byte order
1379 * GUINT16_SWAP_LE_PDP:
1380 * @val: a #guint16 value in little-endian or pdp-endian byte order
1382 * Converts a #guint16 value between little-endian and pdp-endian byte order.
1383 * The conversion is symmetric so it can be used both ways.
1385 * Returns: @val converted to the opposite byte order
1389 * GUINT32_SWAP_BE_PDP:
1390 * @val: a #guint32 value in big-endian or pdp-endian byte order
1392 * Converts a #guint32 value between big-endian and pdp-endian byte order.
1393 * The conversion is symmetric so it can be used both ways.
1395 * Returns: @val converted to the opposite byte order
1399 * GUINT32_SWAP_LE_BE:
1400 * @val: a #guint32 value in little-endian or big-endian byte order
1402 * Converts a #guint32 value between little-endian and big-endian byte order.
1403 * The conversion is symmetric so it can be used both ways.
1405 * Returns: @val converted to the opposite byte order
1409 * GUINT32_SWAP_LE_PDP:
1410 * @val: a #guint32 value in little-endian or pdp-endian byte order
1412 * Converts a #guint32 value between little-endian and pdp-endian byte order.
1413 * The conversion is symmetric so it can be used both ways.
1415 * Returns: @val converted to the opposite byte order
1419 * GUINT64_SWAP_LE_BE:
1420 * @val: a #guint64 value in little-endian or big-endian byte order
1422 * Converts a #guint64 value between little-endian and big-endian byte order.
1423 * The conversion is symmetric so it can be used both ways.
1425 * Returns: @val converted to the opposite byte order
1428 /* Bounds-checked integer arithmetic {{{1 */
1430 * SECTION:checkedmath
1431 * @title: Bounds-checking integer arithmetic
1432 * @short_description: a set of helpers for performing checked integer arithmetic
1434 * GLib offers a set of macros for doing additions and multiplications
1435 * of unsigned integers, with checks for overflows.
1437 * The helpers all have three arguments. A pointer to the destination
1438 * is always the first argument and the operands to the operation are
1441 * Following standard GLib convention, the helpers return %TRUE in case
1442 * of success (ie: no overflow).
1444 * The helpers may be macros, normal functions or inlines. They may be
1445 * implemented with inline assembly or compiler intrinsics where
1452 * g_uint_checked_add
1453 * @dest: a pointer to the #guint destination
1454 * @a: the #guint left operand
1455 * @b: the #guint right operand
1457 * Performs a checked addition of @a and @b, storing the result in
1460 * If the operation is successful, %TRUE is returned. If the operation
1461 * overflows then the state of @dest is undefined and %FALSE is
1464 * Returns: %TRUE if there was no overflow
1469 * g_uint_checked_mul
1470 * @dest: a pointer to the #guint destination
1471 * @a: the #guint left operand
1472 * @b: the #guint right operand
1474 * Performs a checked multiplication of @a and @b, storing the result in
1477 * If the operation is successful, %TRUE is returned. If the operation
1478 * overflows then the state of @dest is undefined and %FALSE is
1481 * Returns: %TRUE if there was no overflow
1486 * g_uint64_checked_add
1487 * @dest: a pointer to the #guint64 destination
1488 * @a: the #guint64 left operand
1489 * @b: the #guint64 right operand
1491 * Performs a checked addition of @a and @b, storing the result in
1494 * If the operation is successful, %TRUE is returned. If the operation
1495 * overflows then the state of @dest is undefined and %FALSE is
1498 * Returns: %TRUE if there was no overflow
1503 * g_uint64_checked_mul
1504 * @dest: a pointer to the #guint64 destination
1505 * @a: the #guint64 left operand
1506 * @b: the #guint64 right operand
1508 * Performs a checked multiplication of @a and @b, storing the result in
1511 * If the operation is successful, %TRUE is returned. If the operation
1512 * overflows then the state of @dest is undefined and %FALSE is
1515 * Returns: %TRUE if there was no overflow
1520 * g_size_checked_add
1521 * @dest: a pointer to the #gsize destination
1522 * @a: the #gsize left operand
1523 * @b: the #gsize right operand
1525 * Performs a checked addition of @a and @b, storing the result in
1528 * If the operation is successful, %TRUE is returned. If the operation
1529 * overflows then the state of @dest is undefined and %FALSE is
1532 * Returns: %TRUE if there was no overflow
1537 * g_size_checked_mul
1538 * @dest: a pointer to the #gsize destination
1539 * @a: the #gsize left operand
1540 * @b: the #gsize right operand
1542 * Performs a checked multiplication of @a and @b, storing the result in
1545 * If the operation is successful, %TRUE is returned. If the operation
1546 * overflows then the state of @dest is undefined and %FALSE is
1549 * Returns: %TRUE if there was no overflow
1552 /* Numerical Definitions {{{1 */
1556 * @title: Numerical Definitions
1557 * @short_description: mathematical constants, and floating point decomposition
1559 * GLib offers mathematical constants such as #G_PI for the value of pi;
1560 * many platforms have these in the C library, but some don't, the GLib
1561 * versions always exist.
1563 * The #GFloatIEEE754 and #GDoubleIEEE754 unions are used to access the
1564 * sign, mantissa and exponent of IEEE floats and doubles. These unions are
1565 * defined as appropriate for a given platform. IEEE floats and doubles are
1566 * supported (used for storage) by at least Intel, PPC and Sparc. See
1567 * [IEEE 754-2008](http://en.wikipedia.org/wiki/IEEE_float)
1568 * for more information about IEEE number formats.
1572 * G_IEEE754_FLOAT_BIAS:
1574 * The bias by which exponents in single-precision floats are offset.
1578 * G_IEEE754_DOUBLE_BIAS:
1580 * The bias by which exponents in double-precision floats are offset.
1585 * @v_float: the double value
1587 * The #GFloatIEEE754 and #GDoubleIEEE754 unions are used to access the sign,
1588 * mantissa and exponent of IEEE floats and doubles. These unions are defined
1589 * as appropriate for a given platform. IEEE floats and doubles are supported
1590 * (used for storage) by at least Intel, PPC and Sparc.
1595 * @v_double: the double value
1597 * The #GFloatIEEE754 and #GDoubleIEEE754 unions are used to access the sign,
1598 * mantissa and exponent of IEEE floats and doubles. These unions are defined
1599 * as appropriate for a given platform. IEEE floats and doubles are supported
1600 * (used for storage) by at least Intel, PPC and Sparc.
1606 * The base of natural logarithms.
1612 * The natural logarithm of 2.
1618 * The natural logarithm of 10.
1624 * The value of pi (ratio of circle's circumference to its diameter).
1642 * The square root of two.
1648 * Multiplying the base 2 exponent by this number yields the base 10 exponent.
1655 * @title: Standard Macros
1656 * @short_description: commonly-used macros
1658 * These macros provide a few commonly-used features.
1664 * This macro is defined only on Windows. So you can bracket
1665 * Windows-specific code in "\#ifdef G_OS_WIN32".
1671 * This macro is defined only on UNIX. So you can bracket
1672 * UNIX-specific code in "\#ifdef G_OS_UNIX".
1678 * The directory separator character.
1679 * This is '/' on UNIX machines and '\' under Windows.
1683 * G_DIR_SEPARATOR_S:
1685 * The directory separator as a string.
1686 * This is "/" on UNIX machines and "\" under Windows.
1690 * G_IS_DIR_SEPARATOR:
1693 * Checks whether a character is a directory
1694 * separator. It returns %TRUE for '/' on UNIX
1695 * machines and for '\' or '/' under Windows.
1701 * G_SEARCHPATH_SEPARATOR:
1703 * The search path separator character.
1704 * This is ':' on UNIX machines and ';' under Windows.
1708 * G_SEARCHPATH_SEPARATOR_S:
1710 * The search path separator as a string.
1711 * This is ":" on UNIX machines and ";" under Windows.
1717 * Defines the %TRUE value for the #gboolean type.
1723 * Defines the %FALSE value for the #gboolean type.
1729 * Defines the standard %NULL pointer.
1734 * @a: a numeric value
1735 * @b: a numeric value
1737 * Calculates the minimum of @a and @b.
1739 * Returns: the minimum of @a and @b.
1744 * @a: a numeric value
1745 * @b: a numeric value
1747 * Calculates the maximum of @a and @b.
1749 * Returns: the maximum of @a and @b.
1754 * @a: a numeric value
1756 * Calculates the absolute value of @a.
1757 * The absolute value is simply the number with any negative sign taken away.
1761 * - ABS(10) is also 10.
1763 * Returns: the absolute value of @a.
1768 * @x: the value to clamp
1769 * @low: the minimum value allowed
1770 * @high: the maximum value allowed
1772 * Ensures that @x is between the limits set by @low and @high. If @low is
1773 * greater than @high the result is undefined.
1776 * - CLAMP(5, 10, 15) is 10.
1777 * - CLAMP(15, 5, 10) is 10.
1778 * - CLAMP(20, 15, 25) is 20.
1780 * Returns: the value of @x clamped to the range between @low and @high
1785 * @member_type: the type of the struct field
1786 * @struct_p: a pointer to a struct
1787 * @struct_offset: the offset of the field from the start of the struct,
1790 * Returns a member of a structure at a given offset, using the given type.
1792 * Returns: the struct member
1796 * G_STRUCT_MEMBER_P:
1797 * @struct_p: a pointer to a struct
1798 * @struct_offset: the offset from the start of the struct, in bytes
1800 * Returns an untyped pointer to a given offset of a struct.
1802 * Returns: an untyped pointer to @struct_p plus @struct_offset bytes
1807 * @struct_type: a structure type, e.g. #GtkWidget
1808 * @member: a field in the structure, e.g. @window
1810 * Returns the offset, in bytes, of a member of a struct.
1812 * Returns: the offset of @member from the start of @struct_type
1818 * If %G_DISABLE_CONST_RETURNS is defined, this macro expands
1819 * to nothing. By default, the macro expands to const. The macro
1820 * can be used in place of const for functions that return a value
1821 * that should not be modified. The purpose of this macro is to allow
1822 * us to turn on const for returned constant strings by default, while
1823 * allowing programmers who find that annoying to turn it off. This macro
1824 * should only be used for return values and for "out" parameters, it
1825 * doesn't make sense for "in" parameters.
1827 * Deprecated: 2.30: API providers should replace all existing uses with
1828 * const and API consumers should adjust their code accordingly
1835 * Determines the number of elements in an array. The array must be
1836 * declared so the compiler knows its size at compile-time; this
1837 * macro will not work on an array allocated on the heap, only static
1838 * arrays or arrays on the stack.
1841 /* Miscellaneous Macros {{{1 */
1844 * SECTION:macros_misc
1845 * @title: Miscellaneous Macros
1846 * @short_description: specialized macros which are not used often
1848 * These macros provide more specialized features which are not
1849 * needed so often by application programmers.
1855 * This macro used to be used to conditionally define inline functions
1856 * in a compatible way before this feature was supported in all
1857 * compilers. These days, GLib requires inlining support from the
1858 * compiler, so your GLib-using programs can safely assume that the
1859 * "inline" keywork works properly.
1861 * Never use this macro anymore. Just say "static inline".
1863 * Deprecated: 2.48: Use "static inline" instead
1869 * Used within multi-statement macros so that they can be used in places
1870 * where only one statement is expected by the compiler.
1876 * Used within multi-statement macros so that they can be used in places
1877 * where only one statement is expected by the compiler.
1883 * Used (along with #G_END_DECLS) to bracket header files. If the
1884 * compiler in use is a C++ compiler, adds extern "C"
1885 * around the header.
1891 * Used (along with #G_BEGIN_DECLS) to bracket header files. If the
1892 * compiler in use is a C++ compiler, adds extern "C"
1893 * around the header.
1898 * @ap1: the va_list variable to place a copy of @ap2 in
1901 * Portable way to copy va_list variables.
1903 * In order to use this function, you must include string.h yourself,
1904 * because this macro may use memmove() and GLib does not include
1910 * @macro_or_string: a macro or a string
1912 * Accepts a macro or a string and converts it into a string after
1913 * preprocessor argument expansion. For example, the following code:
1915 * |[<!-- language="C" -->
1917 * const gchar *greeting = G_STRINGIFY (AGE) " today!";
1920 * is transformed by the preprocessor into (code equivalent to):
1922 * |[<!-- language="C" -->
1923 * const gchar *greeting = "27 today!";
1929 * @identifier1: an identifier
1930 * @identifier2: an identifier
1932 * Yields a new preprocessor pasted identifier
1933 * @identifier1identifier2 from its expanded
1934 * arguments @identifier1 and @identifier2. For example,
1935 * the following code:
1936 * |[<!-- language="C" -->
1937 * #define GET(traveller,method) G_PASTE(traveller_get_, method) (traveller)
1938 * const gchar *name = GET (traveller, name);
1939 * const gchar *quest = GET (traveller, quest);
1940 * GdkColor *favourite = GET (traveller, favourite_colour);
1943 * is transformed by the preprocessor into:
1944 * |[<!-- language="C" -->
1945 * const gchar *name = traveller_get_name (traveller);
1946 * const gchar *quest = traveller_get_quest (traveller);
1947 * GdkColor *favourite = traveller_get_favourite_colour (traveller);
1955 * @expr: a constant expression
1957 * The G_STATIC_ASSERT() macro lets the programmer check
1958 * a condition at compile time, the condition needs to
1959 * be compile time computable. The macro can be used in
1960 * any place where a typedef is valid.
1962 * A typedef is generally allowed in exactly the same places that
1963 * a variable declaration is allowed. For this reason, you should
1964 * not use G_STATIC_ASSERT() in the middle of blocks of code.
1966 * The macro should only be used once per source code line.
1972 * G_STATIC_ASSERT_EXPR:
1973 * @expr: a constant expression
1975 * The G_STATIC_ASSERT_EXPR() macro lets the programmer check
1976 * a condition at compile time. The condition needs to be
1977 * compile time computable.
1979 * Unlike G_STATIC_ASSERT(), this macro evaluates to an expression
1980 * and, as such, can be used in the middle of other expressions.
1981 * Its value should be ignored. This can be accomplished by placing
1982 * it as the first argument of a comma expression.
1984 * |[<!-- language="C" -->
1985 * #define ADD_ONE_TO_INT(x) \
1986 * (G_STATIC_ASSERT_EXPR(sizeof (x) == sizeof (int)), ((x) + 1))
1995 * Expands to __extension__ when gcc is used as the compiler. This simply
1996 * tells gcc not to warn about the following non-standard code when compiling
1997 * with the `-pedantic` option.
2001 * G_GNUC_CHECK_VERSION:
2002 * @major: major version to check against
2003 * @minor: minor version to check against
2005 * Expands to a a check for a compiler with __GNUC__ defined and a version
2006 * greater than or equal to the major and minor numbers provided. For example,
2007 * the following would only match on compilers such as GCC 4.8 or newer.
2009 * |[<!-- language="C" -->
2010 * #if G_GNUC_CHECK_VERSION(4, 8)
2020 * Expands to the GNU C const function attribute if the compiler is gcc.
2021 * Declaring a function as const enables better optimization of calls to
2022 * the function. A const function doesn't examine any values except its
2023 * parameters, and has no effects except its return value.
2025 * Place the attribute after the declaration, just before the semicolon.
2027 * See the GNU C documentation for more details.
2029 * A function that has pointer arguments and examines the data pointed to
2030 * must not be declared const. Likewise, a function that calls a non-const
2031 * function usually must not be const. It doesn't make sense for a const
2032 * function to return void.
2038 * Expands to the GNU C pure function attribute if the compiler is gcc.
2039 * Declaring a function as pure enables better optimization of calls to
2040 * the function. A pure function has no effects except its return value
2041 * and the return value depends only on the parameters and/or global
2044 * Place the attribute after the declaration, just before the semicolon.
2046 * See the GNU C documentation for more details.
2052 * Expands to the GNU C malloc function attribute if the compiler is gcc.
2053 * Declaring a function as malloc enables better optimization of the function.
2054 * A function can have the malloc attribute if it returns a pointer which is
2055 * guaranteed to not alias with any other pointer when the function returns
2056 * (in practice, this means newly allocated memory).
2058 * Place the attribute after the declaration, just before the semicolon.
2060 * See the GNU C documentation for more details.
2066 * G_GNUC_ALLOC_SIZE:
2067 * @x: the index of the argument specifying the allocation size
2069 * Expands to the GNU C alloc_size function attribute if the compiler
2070 * is a new enough gcc. This attribute tells the compiler that the
2071 * function returns a pointer to memory of a size that is specified
2072 * by the @xth function parameter.
2074 * Place the attribute after the function declaration, just before the
2077 * See the GNU C documentation for more details.
2083 * G_GNUC_ALLOC_SIZE2:
2084 * @x: the index of the argument specifying one factor of the allocation size
2085 * @y: the index of the argument specifying the second factor of the allocation size
2087 * Expands to the GNU C alloc_size function attribute if the compiler is a
2088 * new enough gcc. This attribute tells the compiler that the function returns
2089 * a pointer to memory of a size that is specified by the product of two
2090 * function parameters.
2092 * Place the attribute after the function declaration, just before the
2095 * See the GNU C documentation for more details.
2101 * G_GNUC_DEPRECATED:
2103 * Expands to the GNU C deprecated attribute if the compiler is gcc.
2104 * It can be used to mark typedefs, variables and functions as deprecated.
2105 * When called with the `-Wdeprecated-declarations` option,
2106 * gcc will generate warnings when deprecated interfaces are used.
2108 * Place the attribute after the declaration, just before the semicolon.
2110 * See the GNU C documentation for more details.
2116 * G_GNUC_DEPRECATED_FOR:
2117 * @f: the intended replacement for the deprecated symbol,
2118 * such as the name of a function
2120 * Like %G_GNUC_DEPRECATED, but names the intended replacement for the
2121 * deprecated symbol if the version of gcc in use is new enough to support
2122 * custom deprecation messages.
2124 * Place the attribute after the declaration, just before the semicolon.
2126 * See the GNU C documentation for more details.
2128 * Note that if @f is a macro, it will be expanded in the warning message.
2129 * You can enclose it in quotes to prevent this. (The quotes will show up
2130 * in the warning, but it's better than showing the macro expansion.)
2136 * G_GNUC_BEGIN_IGNORE_DEPRECATIONS:
2138 * Tells gcc (if it is a new enough version) to temporarily stop emitting
2139 * warnings when functions marked with %G_GNUC_DEPRECATED or
2140 * %G_GNUC_DEPRECATED_FOR are called. This is useful for when you have
2141 * one deprecated function calling another one, or when you still have
2142 * regression tests for deprecated functions.
2144 * Use %G_GNUC_END_IGNORE_DEPRECATIONS to begin warning again. (If you
2145 * are not compiling with `-Wdeprecated-declarations` then neither macro
2148 * This macro can be used either inside or outside of a function body,
2149 * but must appear on a line by itself.
2155 * G_GNUC_END_IGNORE_DEPRECATIONS:
2157 * Undoes the effect of %G_GNUC_BEGIN_IGNORE_DEPRECATIONS, telling
2158 * gcc to begin outputting warnings again (assuming those warnings
2159 * had been enabled to begin with).
2161 * This macro can be used either inside or outside of a function body,
2162 * but must appear on a line by itself.
2170 * This macro is similar to %G_GNUC_DEPRECATED, and can be used to mark
2171 * functions declarations as deprecated. Unlike %G_GNUC_DEPRECATED, it is
2172 * meant to be portable across different compilers and must be placed
2173 * before the function declaration.
2180 * @f: the name of the function that this function was deprecated for
2182 * This macro is similar to %G_GNUC_DEPRECATED_FOR, and can be used to mark
2183 * functions declarations as deprecated. Unlike %G_GNUC_DEPRECATED_FOR, it
2184 * is meant to be portable across different compilers and must be placed
2185 * before the function declaration.
2192 * @maj: the major version that introduced the symbol
2193 * @min: the minor version that introduced the symbol
2195 * This macro can be used to mark a function declaration as unavailable.
2196 * It must be placed before the function declaration. Use of a function
2197 * that has been annotated with this macros will produce a compiler warning.
2203 * GLIB_DISABLE_DEPRECATION_WARNINGS:
2205 * A macro that should be defined before including the glib.h header.
2206 * If it is defined, no compiler warnings will be produced for uses
2207 * of deprecated GLib APIs.
2213 * Expands to the GNU C noreturn function attribute if the compiler is gcc.
2214 * It is used for declaring functions which never return. It enables
2215 * optimization of the function, and avoids possible compiler warnings.
2217 * Place the attribute after the declaration, just before the semicolon.
2219 * See the GNU C documentation for more details.
2225 * Expands to the GNU C unused function attribute if the compiler is gcc.
2226 * It is used for declaring functions and arguments which may never be used.
2227 * It avoids possible compiler warnings.
2229 * For functions, place the attribute after the declaration, just before the
2230 * semicolon. For arguments, place the attribute at the beginning of the
2231 * argument declaration.
2233 * |[<!-- language="C" -->
2234 * void my_unused_function (G_GNUC_UNUSED gint unused_argument,
2235 * gint other_argument) G_GNUC_UNUSED;
2238 * See the GNU C documentation for more details.
2243 * @format_idx: the index of the argument corresponding to the
2244 * format string (the arguments are numbered from 1)
2245 * @arg_idx: the index of the first of the format arguments, or 0 if
2246 * there are no format arguments
2248 * Expands to the GNU C format function attribute if the compiler is gcc.
2249 * This is used for declaring functions which take a variable number of
2250 * arguments, with the same syntax as printf(). It allows the compiler
2251 * to type-check the arguments passed to the function.
2253 * Place the attribute after the function declaration, just before the
2257 * [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-Wformat-3288)
2260 * |[<!-- language="C" -->
2261 * gint g_snprintf (gchar *string,
2263 * gchar const *format,
2264 * ...) G_GNUC_PRINTF (3, 4);
2270 * @format_idx: the index of the argument corresponding to
2271 * the format string (the arguments are numbered from 1)
2272 * @arg_idx: the index of the first of the format arguments, or 0 if
2273 * there are no format arguments
2275 * Expands to the GNU C format function attribute if the compiler is gcc.
2276 * This is used for declaring functions which take a variable number of
2277 * arguments, with the same syntax as scanf(). It allows the compiler
2278 * to type-check the arguments passed to the function.
2281 * [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-Wformat-3288)
2287 * @arg_idx: the index of the argument
2289 * Expands to the GNU C format_arg function attribute if the compiler
2290 * is gcc. This function attribute specifies that a function takes a
2291 * format string for a printf(), scanf(), strftime() or strfmon() style
2292 * function and modifies it, so that the result can be passed to a printf(),
2293 * scanf(), strftime() or strfmon() style function (with the remaining
2294 * arguments to the format function the same as they would have been
2295 * for the unmodified string).
2297 * Place the attribute after the function declaration, just before the
2300 * See the GNU C documentation for more details.
2302 * |[<!-- language="C" -->
2303 * gchar *g_dgettext (gchar *domain_name, gchar *msgid) G_GNUC_FORMAT (2);
2308 * G_GNUC_NULL_TERMINATED:
2310 * Expands to the GNU C sentinel function attribute if the compiler is gcc.
2311 * This function attribute only applies to variadic functions and instructs
2312 * the compiler to check that the argument list is terminated with an
2315 * Place the attribute after the declaration, just before the semicolon.
2317 * See the GNU C documentation for more details.
2323 * G_GNUC_WARN_UNUSED_RESULT:
2325 * Expands to the GNU C warn_unused_result function attribute if the compiler
2326 * is gcc. This function attribute makes the compiler emit a warning if the
2327 * result of a function call is ignored.
2329 * Place the attribute after the declaration, just before the semicolon.
2331 * See the GNU C documentation for more details.
2339 * Expands to "" on all modern compilers, and to __FUNCTION__ on gcc
2340 * version 2.x. Don't use it.
2342 * Deprecated: 2.16: Use G_STRFUNC() instead
2346 * G_GNUC_PRETTY_FUNCTION:
2348 * Expands to "" on all modern compilers, and to __PRETTY_FUNCTION__
2349 * on gcc version 2.x. Don't use it.
2351 * Deprecated: 2.16: Use G_STRFUNC() instead
2355 * G_GNUC_NO_INSTRUMENT:
2357 * Expands to the GNU C no_instrument_function function attribute if the
2358 * compiler is gcc. Functions with this attribute will not be instrumented
2359 * for profiling, when the compiler is called with the
2360 * `-finstrument-functions` option.
2362 * Place the attribute after the declaration, just before the semicolon.
2364 * See the GNU C documentation for more details.
2370 * This attribute can be used for marking library functions as being used
2371 * internally to the library only, which may allow the compiler to handle
2372 * function calls more efficiently. Note that static functions do not need
2373 * to be marked as internal in this way. See the GNU C documentation for
2376 * When using a compiler that supports the GNU C hidden visibility attribute,
2377 * this macro expands to __attribute__((visibility("hidden"))).
2378 * When using the Sun Studio compiler, it expands to __hidden.
2380 * Note that for portability, the attribute should be placed before the
2381 * function declaration. While GCC allows the macro after the declaration,
2382 * Sun Studio does not.
2384 * |[<!-- language="C" -->
2386 * void _g_log_fallback_handler (const gchar *log_domain,
2387 * GLogLevelFlags log_level,
2388 * const gchar *message,
2389 * gpointer unused_data);
2398 * Expands to the GNU C may_alias type attribute if the compiler is gcc.
2399 * Types with this attribute will not be subjected to type-based alias
2400 * analysis, but are assumed to alias with any other type, just like char.
2402 * See the GNU C documentation for details.
2409 * @expr: the expression
2411 * Hints the compiler that the expression is likely to evaluate to
2412 * a true value. The compiler may use this information for optimizations.
2414 * |[<!-- language="C" -->
2415 * if (G_LIKELY (random () != 1))
2416 * g_print ("not one");
2419 * Returns: the value of @expr
2426 * @expr: the expression
2428 * Hints the compiler that the expression is unlikely to evaluate to
2429 * a true value. The compiler may use this information for optimizations.
2431 * |[<!-- language="C" -->
2432 * if (G_UNLIKELY (random () == 1))
2433 * g_print ("a random one");
2436 * Returns: the value of @expr
2444 * Expands to a string identifying the current code position.
2450 * Expands to a string identifying the current function.
2456 * G_HAVE_GNUC_VISIBILITY:
2458 * Defined to 1 if gcc-style visibility handling is supported.
2461 /* g_auto(), g_autoptr() and helpers {{{1 */
2465 * @TypeName: a supported variable type
2467 * Helper to declare a variable with automatic cleanup.
2469 * The variable is cleaned up in a way appropriate to its type when the
2470 * variable goes out of scope. The type must support this.
2472 * This feature is only supported on GCC and clang. This macro is not
2473 * defined on other compilers and should not be used in programs that
2474 * are intended to be portable to those compilers.
2476 * This is meant to be used with stack-allocated structures and
2477 * non-pointer types. For the (more commonly used) pointer version, see
2480 * This macro can be used to avoid having to do explicit cleanups of
2481 * local variables when exiting functions. It often vastly simplifies
2482 * handling of error conditions, removing the need for various tricks
2483 * such as 'goto out' or repeating of cleanup code. It is also helpful
2484 * for non-error cases.
2486 * Consider the following example:
2492 * g_auto(GQueue) queue = G_QUEUE_INIT;
2493 * g_auto(GVariantBuilder) builder;
2494 * g_auto(GStrv) strv;
2496 * g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT);
2497 * strv = g_strsplit("a:b:c", ":", -1);
2501 * if (error_condition)
2506 * return g_variant_builder_end (&builder);
2510 * You must initialize the variable in some way -- either by use of an
2511 * initialiser or by ensuring that an _init function will be called on
2512 * it unconditionally before it goes out of scope.
2519 * @TypeName: a supported variable type
2521 * Helper to declare a pointer variable with automatic cleanup.
2523 * The variable is cleaned up in a way appropriate to its type when the
2524 * variable goes out of scope. The type must support this.
2526 * This feature is only supported on GCC and clang. This macro is not
2527 * defined on other compilers and should not be used in programs that
2528 * are intended to be portable to those compilers.
2530 * This is meant to be used to declare pointers to types with cleanup
2531 * functions. The type of the variable is a pointer to @TypeName. You
2532 * must not add your own '*'.
2534 * This macro can be used to avoid having to do explicit cleanups of
2535 * local variables when exiting functions. It often vastly simplifies
2536 * handling of error conditions, removing the need for various tricks
2537 * such as 'goto out' or repeating of cleanup code. It is also helpful
2538 * for non-error cases.
2540 * Consider the following example:
2544 * check_exists(GVariant *dict)
2546 * g_autoptr(GVariant) dirname, basename = NULL;
2547 * g_autofree gchar *path = NULL;
2549 * dirname = g_variant_lookup_value (dict, "dirname", G_VARIANT_TYPE_STRING);
2551 * if (dirname == NULL)
2554 * basename = g_variant_lookup_value (dict, "basename", G_VARIANT_TYPE_STRING);
2556 * if (basename == NULL)
2559 * path = g_build_filename (g_variant_get_string (dirname, NULL),
2560 * g_variant_get_string (basename, NULL),
2563 * return g_access (path, R_OK) == 0;
2567 * You must initialise the variable in some way -- either by use of an
2568 * initialiser or by ensuring that it is assigned to unconditionally
2569 * before it goes out of scope.
2571 * See also g_auto(), g_autofree() and g_steal_pointer().
2579 * Macro to add an attribute to pointer variable to ensure automatic
2580 * cleanup using g_free().
2582 * This macro differs from g_autoptr() in that it is an attribute supplied
2583 * before the type name, rather than wrapping the type definition. Instead
2584 * of using a type-specific lookup, this macro always calls g_free() directly.
2586 * This means it's useful for any type that is returned from
2589 * Otherwise, this macro has similar constraints as g_autoptr() - only
2590 * supported on GCC and clang, the variable must be initialized, etc.
2594 * operate_on_malloc_buf (void)
2596 * g_autofree guint8* membuf = NULL;
2598 * membuf = g_malloc (8192);
2600 * // Some computation on membuf
2602 * // membuf will be automatically freed here
2612 * @TypeName: a supported variable type
2614 * Helper to declare a list variable with automatic deep cleanup.
2616 * The list is deeply freed, in a way appropriate to the specified type, when the
2617 * variable goes out of scope. The type must support this.
2619 * This feature is only supported on GCC and clang. This macro is not
2620 * defined on other compilers and should not be used in programs that
2621 * are intended to be portable to those compilers.
2623 * This is meant to be used to declare lists of a type with a cleanup
2624 * function. The type of the variable is a GList *. You
2625 * must not add your own '*'.
2627 * This macro can be used to avoid having to do explicit cleanups of
2628 * local variables when exiting functions. It often vastly simplifies
2629 * handling of error conditions, removing the need for various tricks
2630 * such as 'goto out' or repeating of cleanup code. It is also helpful
2631 * for non-error cases.
2633 * See also g_autoslist(), g_autoptr() and g_steal_pointer().
2640 * @TypeName: a supported variable type
2642 * Helper to declare a singly linked list variable with automatic deep cleanup.
2644 * The list is deeply freed, in a way appropriate to the specified type, when the
2645 * variable goes out of scope. The type must support this.
2647 * This feature is only supported on GCC and clang. This macro is not
2648 * defined on other compilers and should not be used in programs that
2649 * are intended to be portable to those compilers.
2651 * This is meant to be used to declare lists of a type with a cleanup
2652 * function. The type of the variable is a GSList *. You
2653 * must not add your own '*'.
2655 * This macro can be used to avoid having to do explicit cleanups of
2656 * local variables when exiting functions. It often vastly simplifies
2657 * handling of error conditions, removing the need for various tricks
2658 * such as 'goto out' or repeating of cleanup code. It is also helpful
2659 * for non-error cases.
2661 * See also g_autolist(), g_autoptr() and g_steal_pointer().
2667 * G_DEFINE_AUTOPTR_CLEANUP_FUNC:
2668 * @TypeName: a type name to define a g_autoptr() cleanup function for
2669 * @func: the cleanup function
2671 * Defines the appropriate cleanup function for a pointer type.
2673 * The function will not be called if the variable to be cleaned up
2676 * This will typically be the _free() or _unref() function for the given
2679 * With this definition, it will be possible to use g_autoptr() with
2683 * G_DEFINE_AUTOPTR_CLEANUP_FUNC(GObject, g_object_unref)
2686 * This macro should be used unconditionally; it is a no-op on compilers
2687 * where cleanup is not supported.
2693 * G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC:
2694 * @TypeName: a type name to define a g_auto() cleanup function for
2695 * @func: the clear function
2697 * Defines the appropriate cleanup function for a type.
2699 * This will typically be the _clear() function for the given type.
2701 * With this definition, it will be possible to use g_auto() with
2705 * G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(GQueue, g_queue_clear)
2708 * This macro should be used unconditionally; it is a no-op on compilers
2709 * where cleanup is not supported.
2715 * G_DEFINE_AUTO_CLEANUP_FREE_FUNC:
2716 * @TypeName: a type name to define a g_auto() cleanup function for
2717 * @func: the free function
2718 * @none: the "none" value for the type
2720 * Defines the appropriate cleanup function for a type.
2722 * With this definition, it will be possible to use g_auto() with
2725 * This function will be rarely used. It is used with pointer-based
2726 * typedefs and non-pointer types where the value of the variable
2727 * represents a resource that must be freed. Two examples are #GStrv
2728 * and file descriptors.
2730 * @none specifies the "none" value for the type in question. It is
2731 * probably something like %NULL or -1. If the variable is found to
2732 * contain this value then the free function will not be called.
2735 * G_DEFINE_AUTO_CLEANUP_FREE_FUNC(GStrv, g_strfreev, NULL)
2738 * This macro should be used unconditionally; it is a no-op on compilers
2739 * where cleanup is not supported.
2744 /* Windows Compatibility Functions {{{1 */
2748 * @title: Windows Compatibility Functions
2749 * @short_description: UNIX emulation on Windows
2751 * These functions provide some level of UNIX emulation on the
2752 * Windows platform. If your application really needs the POSIX
2753 * APIs, we suggest you try the Cygwin project.
2759 * Provided for UNIX emulation on Windows; equivalent to UNIX
2760 * macro %MAXPATHLEN, which is the maximum length of a filename
2761 * (including full path).
2765 * G_WIN32_DLLMAIN_FOR_DLL_NAME:
2766 * @static: empty or "static"
2767 * @dll_name: the name of the (pointer to the) char array where
2768 * the DLL name will be stored. If this is used, you must also
2769 * include `windows.h`. If you need a more complex DLL entry
2770 * point function, you cannot use this
2772 * On Windows, this macro defines a DllMain() function that stores
2773 * the actual DLL name that the code being compiled will be included in.
2775 * On non-Windows platforms, expands to nothing.
2779 * G_WIN32_HAVE_WIDECHAR_API:
2781 * On Windows, this macro defines an expression which evaluates to
2782 * %TRUE if the code is running on a version of Windows where the wide
2783 * character versions of the Win32 API functions, and the wide character
2784 * versions of the C library functions work. (They are always present in
2785 * the DLLs, but don't work on Windows 9x and Me.)
2787 * On non-Windows platforms, it is not defined.
2794 * G_WIN32_IS_NT_BASED:
2796 * On Windows, this macro defines an expression which evaluates to
2797 * %TRUE if the code is running on an NT-based Windows operating system.
2799 * On non-Windows platforms, it is not defined.
2805 /* vim: set foldmethod=marker: */