All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
attributes.h File Reference

Define function attributes. More...

+ Include dependency graph for attributes.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define ARCH_PRINTF_FUNCTION(_fmt, _firstArg)
 Macro used to indicate a function takes a printf-like specification. More...
 
#define ARCH_SCANF_FUNCTION(_fmt, _firstArg)
 Macro used to indicate a function takes a scanf-like specification. More...
 
#define ARCH_NOINLINE
 Macro used to indicate that a function should never be inlined. More...
 
#define ARCH_UNUSED_ARG
 Macro used to indicate a function parameter may be unused. More...
 
#define ARCH_UNUSED_FUNCTION
 Macro used to indicate a function may be unused. More...
 
#define ARCH_USED_FUNCTION
 Macro used to indicate that a function's code must always be emitted even if not required. More...
 
#define ARCH_CONSTRUCTOR(_name, _priority,...)
 Macro to begin the definition of a function that should be executed by the dynamic loader when the dynamic object (library or program) is loaded. More...
 
#define ARCH_DESTRUCTOR(_name, _priority,...)
 Macro to begin the definition of a function that should be executed by the dynamic loader when the dynamic object (library or program) is unloaded. More...
 
#define _ARCH_CAT_NOEXPAND(a, b)   a ## b
 
#define _ARCH_CAT(a, b)   _ARCH_CAT_NOEXPAND(a, b)
 
#define _ARCH_ENSURE_PER_LIB_INIT(T, prefix)   static Arch_PerLibInit<T> _ARCH_CAT(prefix, __COUNTER__)
 

Detailed Description

Define function attributes.

This file allows you to define architecture-specific or compiler-specific options to be used outside lib/arch.

Definition in file attributes.h.

Macro Definition Documentation

#define ARCH_CONSTRUCTOR (   _name,
  _priority,
  ... 
)

Macro to begin the definition of a function that should be executed by the dynamic loader when the dynamic object (library or program) is loaded.

_priority is used to order the execution of constructors. Valid values are integers in the range [0,255]. Constructors with lower numbers are run first. It is unspecified if these functions are run before or after dynamic initialization of non-local variables.

_name is the name of the function and must be unique across all invocations of ARCH_CONSTRUCTOR in the same translation unit. The remaining arguments should be types for the signature of the function. The types are only to make the name unique (when mangled); the function will be called with no arguments so the arguments must not be used. If you don't need any arguments you must use void.

Definition at line 143 of file attributes.h.

#define ARCH_DESTRUCTOR (   _name,
  _priority,
  ... 
)

Macro to begin the definition of a function that should be executed by the dynamic loader when the dynamic object (library or program) is unloaded.

_priority is used to order the execution of destructors. Valid values are integers in the range [0,255]. Destructors with higher numbers are run first. It is unspecified if these functions are run before or after dynamically initialized non-local variables.

_name is the name of the function and must be unique across all invocations of ARCH_CONSTRUCTOR in the same translation unit. The remaining arguments should be types for the signature of the function. The types are only to make the name unique (when mangled); the function will be called with no arguments so the arguments must not be used. If you don't need any arguments you must use void.

Definition at line 162 of file attributes.h.

#define ARCH_NOINLINE

Macro used to indicate that a function should never be inlined.

This attribute is used as follows:

* void Func(T1 arg1, T2 arg2) ARCH_NOINLINE;
*

Definition at line 75 of file attributes.h.

#define ARCH_PRINTF_FUNCTION (   _fmt,
  _firstArg 
)

Macro used to indicate a function takes a printf-like specification.

This attribute is used as follows:

* void PrintFunc(T1 arg1, T2 arg2, const char* fmt, ...)
*

This indicates that the third argument is the format string, and that the fourth argument is where the var-args corresponding to the format string begin.

Definition at line 51 of file attributes.h.

#define ARCH_SCANF_FUNCTION (   _fmt,
  _firstArg 
)

Macro used to indicate a function takes a scanf-like specification.

This attribute is used as follows:

* void ScanFunc(T1 arg1, T2 arg2, const char* fmt, ...)
*

This indicates that the third argument is the format string, and that the fourth argument is where the var-args corresponding to the format string begin.

Definition at line 65 of file attributes.h.

#define ARCH_UNUSED_ARG

Macro used to indicate a function parameter may be unused.

In general, avoid this attribute if possible. Mostly this attribute should be used when the set of arguments to a function is described as part of a macro. The usage is:

* void Func(T1 arg1, ARCH_UNUSED_ARG T2 arg2, ARCH_UNUSED_ARG T3 arg3, T4 arg4) {
* ...
* }
*

Definition at line 89 of file attributes.h.

#define ARCH_UNUSED_FUNCTION

Macro used to indicate a function may be unused.

In general, avoid this attribute if possible. Mostly this attribute should be used when you need to keep a function around (for some good reason), but it is not used in the rest of the code. The usage is:

* ARCH_UNUSED_FUNCTION void Func() {
* ...
* }
*

Definition at line 104 of file attributes.h.

#define ARCH_USED_FUNCTION

Macro used to indicate that a function's code must always be emitted even if not required.

This attribute is especially useful with templated registration functions, which might not be present in the linked binary if they are not used (or the compiler optimizes away their use.)

The usage is:

* template <typename T>
* struct TraitsClass {
* static void RegistryFunction() ARCH_USED_FUNCTION {
* ...
* }
* };
*

Definition at line 124 of file attributes.h.