Loading...
Searching...
No Matches
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.
 
#define ARCH_SCANF_FUNCTION(_fmt, _firstArg)
 Macro used to indicate a function takes a scanf-like specification.
 
#define ARCH_NOINLINE
 Macro used to indicate that a function should never be inlined.
 
#define ARCH_UNUSED_ARG
 Macro used to indicate a function parameter may be unused.
 
#define ARCH_UNUSED_FUNCTION
 Macro used to indicate a function may be unused.
 
#define ARCH_USED_FUNCTION
 Macro used to indicate that a function's code must always be emitted even if not required.
 
#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.
 
#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.
 
#define ARCH_EMPTY_BASES
 Macro to begin the definition of a class that is using private inheritance to take advantage of the empty base optimization.
 
#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

◆ _ARCH_CAT

#define _ARCH_CAT (   a,
 
)    _ARCH_CAT_NOEXPAND(a, b)

Definition at line 227 of file attributes.h.

◆ _ARCH_CAT_NOEXPAND

#define _ARCH_CAT_NOEXPAND (   a,
 
)    a ## b

Definition at line 226 of file attributes.h.

◆ _ARCH_ENSURE_PER_LIB_INIT

#define _ARCH_ENSURE_PER_LIB_INIT (   T,
  prefix 
)     static Arch_PerLibInit<T> _ARCH_CAT(prefix, __COUNTER__)

Definition at line 228 of file attributes.h.

◆ ARCH_CONSTRUCTOR

#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.

◆ ARCH_DESTRUCTOR

#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.

◆ ARCH_EMPTY_BASES

#define ARCH_EMPTY_BASES

Macro to begin the definition of a class that is using private inheritance to take advantage of the empty base optimization.

Some compilers require an explicit tag.

In C++20, usage of private inheritance may be able to be retired with the [[no_unique_address]] tag.

Definition at line 170 of file attributes.h.

◆ ARCH_NOINLINE

#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;
#define ARCH_NOINLINE
Macro used to indicate that a function should never be inlined.
Definition: attributes.h:75

Definition at line 75 of file attributes.h.

◆ ARCH_PRINTF_FUNCTION

#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, ...)
#define ARCH_PRINTF_FUNCTION(_fmt, _firstArg)
Macro used to indicate a function takes a printf-like specification.
Definition: attributes.h:51

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.

◆ ARCH_SCANF_FUNCTION

#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.

◆ ARCH_UNUSED_ARG

#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) {
...
}
#define ARCH_UNUSED_ARG
Macro used to indicate a function parameter may be unused.
Definition: attributes.h:89

Definition at line 89 of file attributes.h.

◆ ARCH_UNUSED_FUNCTION

#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() {
...
}
#define ARCH_UNUSED_FUNCTION
Macro used to indicate a function may be unused.
Definition: attributes.h:104

Definition at line 104 of file attributes.h.

◆ ARCH_USED_FUNCTION

#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 {
...
}
};
#define ARCH_USED_FUNCTION
Macro used to indicate that a function's code must always be emitted even if not required.
Definition: attributes.h:124

Definition at line 124 of file attributes.h.