Miscellaneous Macros

Miscellaneous Macros — macros used in liblangtag

Functions

Types and Values

Description

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

Functions

LT_GNUC_PRINTF()

#define             LT_GNUC_PRINTF(format_idx, arg_idx)

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.

Parameters

format_idx

the index of the argument corresponding to the format string. (The arguments are numberered from 1).

 

arg_idx

the index of the first of the format arguments.

 

LT_LIKELY()

#  define LT_LIKELY(_e_) (__builtin_expect (_LT_BOOLEAN_EXPR (_e_), 1))

Hints the compiler that the expression is likely to evaluate to a true value. The compiler may use this information for optimizations.

Parameters

_e_

the expression

 

Returns

the value of expr .


LT_UNLIKELY()

#  define LT_UNLIKELY(_e_) (__builtin_expect (_LT_BOOLEAN_EXPR (_e_), 0))

Hints the compiler that the expression is unlikely to evaluate to a true value. The compiler may use this information for optimizations.

Parameters

_e_

the expression

 

Returns

the value of expr .


LT_GNUC_DEPRECATED_FOR()

#define LT_GNUC_DEPRECATED_FOR(f) __attribute__((deprecated("Use " #f " instead")))

LT_ALIGNED_TO()

#define LT_ALIGNED_TO(_x_,_y_)		(((_x_) + (_y_) - 1) & ~((_y_) - 1))

LT_ALIGNED_TO_POINTER()

#define LT_ALIGNED_TO_POINTER(_x_) LT_ALIGNED_TO ((_x_), ALIGNOF_VOID_P)

LT_N_ELEMENTS()

#define LT_N_ELEMENTS(_x_)		(sizeof (_x_) / sizeof ((_x_)[0]))

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.

Parameters

_x_

the array

 

Returns

the number of elements.


LT_BREAKPOINT

#define             LT_BREAKPOINT()

LT_ASSERT_STATIC()

#define LT_ASSERT_STATIC(_x_)		_LT_ASSERT_STATIC0 (__LINE__, (_x_))

lt_copy_func_t ()

lt_pointer_t
(*lt_copy_func_t) (lt_pointer_t data);

The type of callback function used for copying data .

Parameters

data

the object to be copied.

 

lt_destroy_func_t ()

void
(*lt_destroy_func_t) (lt_pointer_t data);

The type of callback function used for destroying data .

Parameters

data

the object to be destroyed.

 

lt_compare_func_t ()

int
(*lt_compare_func_t) (const lt_pointer_t v1,
                      const lt_pointer_t v2);

The type of callback function used for comparing objects.

Parameters

v1

the object to compare with v2 .

 

v2

the object to compare with v1 .

 

Types and Values

LT_BEGIN_DECLS

#  define LT_BEGIN_DECLS extern "C" {

Used (along with LT_END_DECLS) to bracket header files. If the compiler in use is a C++ compiler, adds extern "C" around the header.


LT_END_DECLS

#  define LT_END_DECLS		}

Used (along with LT_BEGIN_DECLS) to bracket header files. If the compiler in use is a C++ compiler, adds extern "C" around the header.


LT_STMT_START

#  define LT_STMT_START		do

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


LT_STMT_END

#  define LT_STMT_END		while (0)

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


inline

#  define inline __inline__

LT_INLINE_FUNC

#  define LT_INLINE_FUNC static __inline __attribute__ ((unused))

This macro is used to export function prototypes so they can be linked with an external version when no inlining is performed.


LT_GNUC_UNUSED

#define             LT_GNUC_UNUSED

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

For functions, place the attribute after the declaration, just before the semicolon. For arguments, place the attribute at the beginning of the argument declaration.

1
2
void my_unused_function (LT_GNUC_UNUSED int unused_argument,
                         int other argument) LT_GNUC_UNUSED;

See the GNU C documentation for more details.


LT_GNUC_NULL_TERMINATED

#define             LT_GNUC_NULL_TERMINATED

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.


LT_GNUC_DEPRECATED

#define LT_GNUC_DEPRECATED __attribute__((__deprecated__))

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 -Wdeprecated-declarations option. gcc will generate warnings when deprecated interfaces are used.

Place the attribute after the declaration, just before the semicolon.

See the GNU C documentation for more details.


LT_GNUC_BEGIN_IGNORE_DEPRECATIONS

#define             LT_GNUC_BEGIN_IGNORE_DEPRECATIONS

LT_GNUC_END_IGNORE_DEPRECATIONS

#define             LT_GNUC_END_IGNORE_DEPRECATIONS

LT_DIR_SEPARATOR_S

#  define LT_DIR_SEPARATOR_S		"\\"

LT_DIR_SEPARATOR

#  define LT_DIR_SEPARATOR		'\\'

LT_SEARCHPATH_SEPARATOR_S

#  define LT_SEARCHPATH_SEPARATOR_S ";"

LT_SEARCHPATH_SEPARATOR

#  define LT_SEARCHPATH_SEPARATOR ';'

LT_MAX

#  define LT_MAX		MAX

LT_MIN

#  define LT_MIN		MIN

LT_PATH_MAX

#define LT_PATH_MAX 512

ssize_t

typedef signed long long ssize_t;

lt_pointer_t

typedef void *		lt_pointer_t;

The type of object pointer.


lt_bool_t

typedef int		lt_bool_t;

The type of boolean value.