Miscellaneous Macros

Name

Miscellaneous Macros -- specialised macros which are not used often.

Synopsis


#include <glib.h>


#define     G_INLINE_FUNC

#define     G_STMT_START
#define     G_STMT_END

#define     G_BEGIN_DECLS
#define     G_END_DECLS

#define     G_N_ELEMENTS                    (arr)

#define     G_VA_COPY

#define     G_STRINGIFY                     (macro_or_string)

#define     G_GNUC_EXTENSION
#define     G_GNUC_CONST
#define     G_GNUC_NORETURN
#define     G_GNUC_UNUSED
#define     G_GNUC_PURE
#define     G_GNUC_PRINTF                   ( format_idx, arg_idx )
#define     G_GNUC_SCANF                    ( format_idx, arg_idx )
#define     G_GNUC_FORMAT                   ( arg_idx )
#define     G_GNUC_FUNCTION
#define     G_GNUC_PRETTY_FUNCTION

#define     G_STRLOC

#define     G_GINT16_FORMAT
#define     G_GUINT16_FORMAT
#define     G_GINT32_FORMAT
#define     G_GUINT32_FORMAT
#define     G_GINT64_FORMAT
#define     G_GUINT64_FORMAT

Description

These macros provide more specialized features which are not needed so often by application programmers.

Details

G_INLINE_FUNC

#define     G_INLINE_FUNC

Used to declare inline functions. If inline functions are not supported on the particular platform, the macro evaluates to the empty string.


G_STMT_START

#define     G_STMT_START

Used within multi-statement macros so that they can be used in places where only one statement is expected by the compiler.


G_STMT_END

#define     G_STMT_END

Used within multi-statement macros so that they can be used in places where only one statement is expected by the compiler.


G_BEGIN_DECLS

#define     G_BEGIN_DECLS


G_END_DECLS

#define     G_END_DECLS


G_N_ELEMENTS()

#define G_N_ELEMENTS(arr)		(sizeof (arr) / sizeof ((arr)[0]))

arr : 


G_VA_COPY

#define     G_VA_COPY

Portable way to copy va_list variables.


G_STRINGIFY()

#define G_STRINGIFY(macro_or_string)	G_STRINGIFY_ARG (macro_or_string)

macro_or_string : 


G_GNUC_EXTENSION

#define     G_GNUC_EXTENSION

Expands to "__extension__" when GNU C is used as the compiler. This simply tells GNU C not to warn about the following non-standard code when compiling with the -pedantic option.


G_GNUC_CONST

#define     G_GNUC_CONST

Expands to the GNU C const function attribute if the compiler is GNU C. This enables optimization of the function. See the GNU C documentation for details.


G_GNUC_NORETURN

#define     G_GNUC_NORETURN

Expands to the GNU C noreturn function attribute if the compiler is GNU C. 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.


G_GNUC_UNUSED

#define     G_GNUC_UNUSED

Expands to the GNU C unused function attribute if the compiler is GNU C. It is used for declaring functions which may never be used. It avoids possible compiler warnings. See the GNU C documentation for details.


G_GNUC_PURE

#define     G_GNUC_PURE


G_GNUC_PRINTF()

#define     G_GNUC_PRINTF( format_idx, arg_idx )

Expands to the GNU C format function attribute if the compiler is GNU C. 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.

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.


G_GNUC_SCANF()

#define     G_GNUC_SCANF( format_idx, arg_idx )

Expands to the GNU C format function attribute if the compiler is GNU C. 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.


G_GNUC_FORMAT()

#define     G_GNUC_FORMAT( arg_idx )

Expands to the GNU C format_arg function attribute if the compiler is GNU C. This is used for declaring functions which take a variable number of parameters, like printf() and scanf(). See the GNU C documentation for details. FIXME: I can't find this in my GNU C documentation. Take out?

arg_idx :the index of the argument.


G_GNUC_FUNCTION

#define     G_GNUC_FUNCTION

Expands to the GNU C __FUNCTION__ variable if the compiler is GNU C, or "" if it isn't. The GNU C __FUNCTION__ variable contains the name of the current function. See the GNU C documentation for details.


G_GNUC_PRETTY_FUNCTION

#define     G_GNUC_PRETTY_FUNCTION

Expands to the GNU C __PRETTY_FUNCTION__ variable if the compiler is GNU C, or "" if it isn't. The GNU C __PRETTY_FUNCTION__ variable contains the name of the current function. For a C program this is the same as the __FUNCTION__ variable but for C++ it also includes extra information such as the class and function prototype. See the GNU C documentation for details.


G_STRLOC

#define     G_STRLOC


G_GINT16_FORMAT

#define G_GINT16_FORMAT "hi"

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);


G_GUINT16_FORMAT

#define G_GUINT16_FORMAT "hu"

This is the platform dependent conversion specifier for scanning and printing values of type guint16. See also G_GINT16_FORMAT.


G_GINT32_FORMAT

#define G_GINT32_FORMAT "i"

This is the platform dependent conversion specifier for scanning and printing values of type gint32. See also G_GINT16_FORMAT.


G_GUINT32_FORMAT

#define G_GUINT32_FORMAT "u"

This is the platform dependent conversion specifier for scanning and printing values of type guint32. See also G_GINT16_FORMAT.


G_GINT64_FORMAT

#define G_GINT64_FORMAT "lli"

This is the platform dependent conversion specifier for scanning and printing values of type gint64. See also G_GINT16_FORMAT.

Note: 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.


G_GUINT64_FORMAT

#define G_GUINT64_FORMAT "llu"

This is the platform dependent conversion specifier for scanning and printing values of type guint64. See also G_GINT16_FORMAT.

Note: 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.