CLibs
|
Function and variable attributes. More...
Go to the source code of this file.
Macros | |
#define | HAS_ATTRIBUTE(TOK) |
#define | UsageOptional __attribute__( ( __unused__ ) ) |
Stops compiler warnings when the function/variable is unused. | |
#define | PrintfLike(FORMAT_STRING, FIRST_VAR_ARG) |
Tells the compiler which varargs correspond to a format string. | |
#define | ScanfLike(FORMAT_STRING, FIRST_VAR_ARG) |
Tells the compiler which varargs correspond to a format string. | |
#define | UseResult __attribute__( ( __warn_unused_result__ ) ) |
Function's return value must be used. | |
#define | Cold __attribute__( ( __cold__ ) ) |
#define | Const __attribute__( ( __const__ ) ) |
#define | BeforeMain __attribute__( ( constructor ) ) |
Function runs before entering main | |
#define | NoReturn __attribute__( ( noreturn ) ) |
Function always exits. | |
#define | Deprecated __attribute__( ( deprecated ) ) |
Function is deprecated and shouldn't be used. | |
#define | Constructor UseResult |
#define | Private static |
#define | LibraryDefined static UsageOptional |
#define | Mathematical Const |
#define | NonNullParams(...) |
Function and variable attributes.
Whether the compiler supports attributes (GCC/Clang) or not, this header creates platform-independent macros for certain attributes a function or variable may have.
Some combinations may (definitely will) be missing; this isn't an exhaustive list. (Though all macros are safe to use, no matter the compiler)
#define BeforeMain __attribute__( ( constructor ) ) |
Function runs before entering main
#define Cold __attribute__( ( __cold__ ) ) |
#define Const __attribute__( ( __const__ ) ) |
Functions return value only depends on its parameters
#define Constructor UseResult |
Function allocates memory for an object. Not using function's return value results in a memory leak (or worse).
#define Deprecated __attribute__( ( deprecated ) ) |
Function is deprecated and shouldn't be used.
#define HAS_ATTRIBUTE | ( | TOK | ) |
Evaluates as true if the compiler (clang/GCC) supports the attribute
#define LibraryDefined static UsageOptional |
Function or variable is defined in a header file
#define Mathematical Const |
Function has no effect except for the return value. Function's return value only depends on its parameters.
#define NonNullParams | ( | ... | ) |
Must not be NULL
#define NoReturn __attribute__( ( noreturn ) ) |
Function always exits.
#define PrintfLike | ( | FORMAT_STRING, | |
FIRST_VAR_ARG ) |
Tells the compiler which varargs correspond to a format string.
#define Private static |
Function or variable is not visible outside the current file
#define ScanfLike | ( | FORMAT_STRING, | |
FIRST_VAR_ARG ) |
Tells the compiler which varargs correspond to a format string.
#define UsageOptional __attribute__( ( __unused__ ) ) |
Stops compiler warnings when the function/variable is unused.
#define UseResult __attribute__( ( __warn_unused_result__ ) ) |
Function's return value must be used.