Miscellaneous Macros specialized macros which are not used often These macros provide more specialized features which are not needed so often by application programmers. This macro is used to export function prototypes so they can be linked with an external version when no inlining is performed. The file which implements the functions should define %G_IMPLEMENTS_INLINES before including the headers which contain %G_INLINE_FUNC declarations. Since inlining is very compiler-dependent using these macros correctly is very difficult. Their use is strongly discouraged. This macro is often mistaken for a replacement for the inline keyword; inline is already declared in a portable manner in the glib headers and can be used normally. Used within multi-statement macros so that they can be used in places where only one statement is expected by the compiler. Used within multi-statement macros so that they can be used in places where only one statement is expected by the compiler. Used (along with #G_END_DECLS) to bracket header files. If the compiler in use is a C++ compiler, adds extern "C" around the header. Used (along with #G_BEGIN_DECLS) to bracket header files. If the compiler in use is a C++ compiler, adds extern "C" around the header. Determines the number of elements in an array. The array must be declared so the compiler knows its size at compile-time; this macro will not work on an array allocated on the heap, only static arrays or arrays on the stack. @arr: the array Portable way to copy va_list variables. In order to use this function, you must include string.h yourself, because this macro may use memmove() and GLib does not include string.h for you. @ap1: the va_list variable to place a copy of @ap2 in. @ap2: a va_list. Accepts a macro or a string and converts it into a string after preprocessor argument expansion. For example, the following code: #define AGE 27 const gchar *greeting = G_STRINGIFY (AGE) " today!"; is transformed by the preprocessor into (code equivalent to): const gchar *greeting = "27 today!"; @macro_or_string: a macro or a string. Yields a new preprocessor pasted identifier identifier1identifier2 from its expanded arguments @identifier1 and @identifier2. For example, the following code: #define GET(traveller,method) G_PASTE(traveller_get_, method) (traveller) const gchar *name = GET (traveller, name); const gchar *quest = GET (traveller, quest); GdkColor *favourite = GET (traveller, favourite_colour); is transformed by the preprocessor into: const gchar *name = traveller_get_name (traveller); const gchar *quest = traveller_get_quest (traveller); GdkColor *favourite = traveller_get_favourite_colour (traveller); @identifier1: an identifier @identifier2: an identifier @Since: 2.20 The G_STATIC_ASSERT macro lets the programmer check a condition at compile time, the condition needs to be compile time computable. The macro can be used in any place where a typedef is valid. The macro should only be used once per source code line. @expr: a constant expression. @Since: 2.20 Expands to __extension__ when gcc is used as the compiler. This simply tells gcc not to warn about the following non-standard code when compiling with the option. Expands to the GNU C const function attribute if the compiler is gcc. Declaring a function as const enables better optimization of calls to the function. A const function doesn't examine any values except its parameters, and has no effects except its return value. See the GNU C documentation for details. A function that has pointer arguments and examines the data pointed to must not be declared const. Likewise, a function that calls a non-const function usually must not be const. It doesn't make sense for a const function to return void. Expands to the GNU C pure function attribute if the compiler is gcc. Declaring a function as pure enables better optimization of calls to the function. A pure function has no effects except its return value and the return value depends only on the parameters and/or global variables. See the GNU C documentation for details. Expands to the GNU C malloc function attribute if the compiler is gcc. Declaring a function as malloc enables better optimization of the function. A function can have the malloc attribute if it returns a pointer which is guaranteed to not alias with any other pointer when the function returns (in practice, this means newly allocated memory). See the GNU C documentation for details. @Since: 2.6 Expands to the GNU C alloc_size function attribute if the compiler is a new enough gcc. This attribute tells the compiler that the function returns a pointer to memory of a size that is specified by the @xth function parameter. See the GNU C documentation for details. @x: the index of the argument specifying the allocation size @Since: 2.18 Expands to the GNU C alloc_size function attribute if the compiler is a new enough gcc. This attribute tells the compiler that the function returns a pointer to memory of a size that is specified by the product of two function parameters. See the GNU C documentation for details. @x: the index of the argument specifying one factor of the allocation size @y: the index of the argument specifying the second factor of the allocation size @Since: 2.18 Expands to the GNU C deprecated attribute if the compiler is gcc. It can be used to mark typedefs, variables and functions as deprecated. When called with the option, the compiler will generate warnings when deprecated interfaces are used. See the GNU C documentation for details. @Since: 2.2 Like %G_GNUC_DEPRECATED, but names the intended replacement for the deprecated symbol if the version of gcc in use is new enough to support custom deprecation messages. See the GNU C documentation for details. @f: the intended replacement for the deprecated symbol, such as the name of a function @Since: 2.25.3 Expands to the GNU C noreturn function attribute if the compiler is gcc. It is used for declaring functions which never return. It enables optimization of the function, and avoids possible compiler warnings. See the GNU C documentation for details. Expands to the GNU C unused function attribute if the compiler is gcc. It is used for declaring functions which may never be used. It avoids possible compiler warnings. See the GNU C documentation for details. Expands to the GNU C format function attribute if the compiler is gcc. This is used for declaring functions which take a variable number of arguments, with the same syntax as printf(). It allows the compiler to type-check the arguments passed to the function. See the GNU C documentation for details. gint g_snprintf (gchar *string, gulong n, gchar const *format, ...) G_GNUC_PRINTF (3, 4); @format_idx: the index of the argument corresponding to the format string. (The arguments are numbered from 1). @arg_idx: the index of the first of the format arguments. Expands to the GNU C format function attribute if the compiler is gcc. This is used for declaring functions which take a variable number of arguments, with the same syntax as scanf(). It allows the compiler to type-check the arguments passed to the function. See the GNU C documentation for details. @format_idx: the index of the argument corresponding to the format string. (The arguments are numbered from 1). @arg_idx: the index of the first of the format arguments. Expands to the GNU C format_arg function attribute if the compiler is gcc. This function attribute specifies that a function takes a format string for a printf(), scanf(), strftime() or strfmon() style function and modifies it, so that the result can be passed to a printf(), scanf(), strftime() or strfmon() style function (with the remaining arguments to the format function the same as they would have been for the unmodified string). See the GNU C documentation for details. gchar *g_dgettext (gchar *domain_name, gchar *msgid) G_GNUC_FORMAT (2); @arg_idx: the index of the argument. Expands to the GNU C sentinel function attribute if the compiler is gcc, or "" if it isn't. This function attribute only applies to variadic functions and instructs the compiler to check that the argument list is terminated with an explicit %NULL. See the GNU C documentation for details. Since: 2.8 Expands to the GNU C warn_unused_result function attribute if the compiler is gcc, or "" if it isn't. This function attribute makes the compiler emit a warning if the result of a function call is ignored. See the GNU C documentation for details. @Since: 2.10 Expands to "" on all modern compilers, and to __FUNCTION__ on gcc version 2.x. Don't use it. @Deprecated: 2.16: Use #G_STRFUNC instead. Expands to "" on all modern compilers, and to __PRETTY_FUNCTION__ on gcc version 2.x. Don't use it. @Deprecated: 2.16: Use #G_STRFUNC instead. Expands to the GNU C no_instrument_function function attribute if the compiler is gcc. Functions with this attribute will not be instrumented for profiling, when the compiler is called with the option. See the GNU C documentation for details. This attribute can be used for marking library functions as being used internally to the library only, which may allow the compiler to handle function calls more efficiently. Note that static functions do not need to be marked as internal in this way. See the GNU C documentation for details. When using a compiler that supports the GNU C hidden visibility attribute, this macro expands to __attribute__((visibility("hidden"))). When using the Sun Studio compiler, it expands to __hidden. Note that for portability, the attribute should be placed before the function declaration. While GCC allows the macro after the declaration, Sun Studio does not. G_GNUC_INTERNAL void _g_log_fallback_handler (const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer unused_data); Since: 2.6 Expands to the GNU C may_alias type attribute if the compiler is gcc. Types with this attribute will not be subjected to type-based alias analysis, but are assumed to alias with any other type, just like char. See the GNU C documentation for details. Since: 2.14 Hints the compiler that the expression is likely to evaluate to a true value. The compiler may use this information for optimizations. if (G_LIKELY (random () != 1)) g_print ("not one"); @expr: the expression @Returns: the value of @expr @Since: 2.2 Hints the compiler that the expression is unlikely to evaluate to a true value. The compiler may use this information for optimizations. if (G_UNLIKELY (random () == 1)) g_print ("a random one"); @expr: the expression @Returns: the value of @expr @Since: 2.2 Expands to a string identifying the current code position. Expands to a string identifying the current function. @Since: 2.4 The platform dependent length modifier for conversion specifiers for scanning and printing values of type #gint16 or #guint16. It is a string literal, but doesn't include the percent-sign, such that you can add precision and length modifiers between percent-sign and conversion specifier and append a conversion specifier. The following example prints "0x7b"; gint16 value = 123; g_print ("%#" G_GINT16_MODIFIER "x", value); @Since: 2.4 This is the platform dependent conversion specifier for scanning and printing values of type #gint16. It is a string literal, but doesn't include the percent-sign, such that you can add precision and length modifiers between percent-sign and conversion specifier. gint16 in; gint32 out; sscanf ("42", "%" G_GINT16_FORMAT, &in) out = in * 1000; g_print ("%" G_GINT32_FORMAT, out); This is the platform dependent conversion specifier for scanning and printing values of type #guint16. See also #G_GINT16_FORMAT. The platform dependent length modifier for conversion specifiers for scanning and printing values of type #gint32 or #guint32. It is a string literal, See also #G_GINT16_MODIFIER. @Since: 2.4 This is the platform dependent conversion specifier for scanning and printing values of type #gint32. See also #G_GINT16_FORMAT. This is the platform dependent conversion specifier for scanning and printing values of type #guint32. See also #G_GINT16_FORMAT. The platform dependent length modifier for conversion specifiers for scanning and printing values of type #gint64 or #guint64. It is a string literal. Some platforms do not support printing 64 bit integers, even though the types are supported. On such platforms #G_GINT64_MODIFIER is not defined. @Since: 2.4 This is the platform dependent conversion specifier for scanning and printing values of type #gint64. See also #G_GINT16_FORMAT. Some platforms do not support scanning and printing 64 bit integers, even though the types are supported. On such platforms #G_GINT64_FORMAT is not defined. Note that scanf() may not support 64 bit integers, even if #G_GINT64_FORMAT is defined. Due to its weak error handling, scanf() is not recommended for parsing anyway; consider using g_ascii_strtoull() instead. This is the platform dependent conversion specifier for scanning and printing values of type #guint64. See also #G_GINT16_FORMAT. Some platforms do not support scanning and printing 64 bit integers, even though the types are supported. On such platforms #G_GUINT64_FORMAT is not defined. Note that scanf() may not support 64 bit integers, even if #G_GINT64_FORMAT is defined. Due to its weak error handling, scanf() is not recommended for parsing anyway; consider using g_strtoull() instead. The platform dependent length modifier for conversion specifiers for scanning and printing values of type #gsize or #gssize. It is a string literal, @Since: 2.6 This is the platform dependent conversion specifier for scanning and printing values of type #gsize. See also #G_GINT16_FORMAT. @Since: 2.6 This is the platform dependent conversion specifier for scanning and printing values of type #gssize. See also #G_GINT16_FORMAT. @Since: 2.6 The platform dependent length modifier for conversion specifiers for scanning and printing values of type #goffset. It is a string literal. See also #G_GINT64_MODIFIER. @Since: 2.20 This is the platform dependent conversion specifier for scanning and printing values of type #goffset. See also #G_GINT64_FORMAT. Since: 2.20 The platform dependent length modifier for conversion specifiers for scanning and printing values of type #gintptr or #guintptr. It is a string literal. @Since: 2.22 This is the platform dependent conversion specifier for scanning and printing values of type #gintptr. @Since: 2.22 This is the platform dependent conversion specifier for scanning and printing values of type #guintptr. @Since: 2.22