Convenience macros for GCC function, variable, and type attributes. More...
Macros | |
| #define | ATTRIBUTE(X) |
| General-purpose attribute wrapper. | |
| #define | ACCESS(mode, ref_idx) |
| Specifies pointer access mode for function arguments. | |
| #define | ALIAS(target) |
| Creates a symbol alias to another function or variable. | |
| #define | ALIGNED __attribute__((aligned)) |
| Specifies a minimum alignment (in bytes) for a variable or struct. | |
| #define | ALWAYS_INLINE __attribute__((always_inline)) |
| Forces a function to always be inlined. | |
| #define | CONST __attribute__((const)) |
| Marks a function as having no side effects and not depending on global memory. | |
| #define | CONSTRUCTOR __attribute__((constructor)) |
| Marks a function to be called automatically before main(). | |
| #define | DESTRUCTOR __attribute__((destructor)) |
| Marks a function to be called automatically after main() returns. | |
| #define | DEPRECATED __attribute__((deprecated)) |
| Marks a function or variable as deprecated. | |
| #define | DEPRECATED_MSG(msg) |
| Marks a function or variable as deprecated, with a custom message. | |
| #define | ERROR(msg) |
| Triggers a compile-time error if the function is used. | |
| #define | WARNING(msg) |
| Triggers a compile-time warning if the function is used. | |
| #define | FD_ARG(n) |
| Indicates a function parameter is a file descriptor. | |
| #define | FD_ARG_READ(n) |
| Indicates a file descriptor parameter is used for reading. | |
| #define | FD_ARG_WRITE(n) |
| Indicates a file descriptor parameter is used for writing. | |
| #define | FORMAT(archetype, string_index, first_to_check) |
| Specifies printf/scanf-style format checking. | |
| #define | FORMAT_ARG(string_index) |
| Applies format checking to a string-returning function. | |
| #define | MALLOC(deallocator) |
| Marks function as returning freshly allocated memory. | |
| #define | NONNULL __attribute__((nonnull)) |
| Marks all pointer arguments as non-null. | |
| #define | NONNULL_POSITIONS(...) |
| Marks specific pointer arguments as non-null. | |
| #define | NORETURN __attribute__((noreturn)) |
| Indicates a function never returns. | |
| #define | NOTHROW __attribute__((nothrow)) |
| Indicates the function does not throw exceptions. | |
| #define | NULL_TERMINATED_STRING_ARG(n) |
| Marks a string argument as null-terminated. | |
| #define | PURE __attribute__((pure)) |
| Marks a function as having no side effects except return value. | |
| #define | RETURN_NONNULL __attribute__((return_nonnull)) |
| Declares that the function never returns a null pointer. | |
| #define | SENTINEL __attribute__((sentinel)) |
| Marks the last argument in a variadic function as a sentinel (e.g., NULL). | |
| #define | UNAVAILABLE __attribute__((unavailable)) |
| Marks a function or variable as unavailable. | |
| #define | UNAVAILABLE_MSG(msg) |
| Marks a function or variable as unavailable, with a message. | |
| #define | UNUSED __attribute__((unused)) |
| Marks a variable or function as possibly unused to suppress warnings. | |
| #define | USED __attribute__((used)) |
| Marks a symbol to be emitted even if it appears unused. | |
| #define | WARN_UNUSED_RESULT __attribute__((warn_unused_result)) |
| Warns if the result of a function is ignored. | |
| #define | UNREACHABLE __builtin_unreachable() |
| Hints to the compiler that the following code is unreachable. | |
Convenience macros for GCC function, variable, and type attributes.
This header provides wrappers for various GCC __attribute__ extensions.
| #define ACCESS | ( | mode, | |
| ref_idx ) |
Specifies pointer access mode for function arguments.
| mode | Access mode: "read_only", "write_only", or "read_write". |
| ref_idx | Index of the pointer argument being accessed. |
| #define ALIAS | ( | target | ) |
Creates a symbol alias to another function or variable.
| target | The target symbol name (as a token). |
| #define ALIGNED __attribute__((aligned)) |
Specifies a minimum alignment (in bytes) for a variable or struct.
| #define ALWAYS_INLINE __attribute__((always_inline)) |
Forces a function to always be inlined.
| #define ATTRIBUTE | ( | X | ) |
General-purpose attribute wrapper.
| #define CONST __attribute__((const)) |
Marks a function as having no side effects and not depending on global memory.
| #define CONSTRUCTOR __attribute__((constructor)) |
Marks a function to be called automatically before main().
| #define DEPRECATED __attribute__((deprecated)) |
Marks a function or variable as deprecated.
| #define DEPRECATED_MSG | ( | msg | ) |
Marks a function or variable as deprecated, with a custom message.
| msg | Message explaining why it's deprecated. |
| #define DESTRUCTOR __attribute__((destructor)) |
Marks a function to be called automatically after main() returns.
| #define ERROR | ( | msg | ) |
Triggers a compile-time error if the function is used.
| msg | Error message to display. |
| #define FD_ARG | ( | n | ) |
Indicates a function parameter is a file descriptor.
| n | 1-based index of the parameter. |
| #define FD_ARG_READ | ( | n | ) |
Indicates a file descriptor parameter is used for reading.
| n | 1-based index of the parameter. |
| #define FD_ARG_WRITE | ( | n | ) |
Indicates a file descriptor parameter is used for writing.
| n | 1-based index of the parameter. |
| #define FORMAT | ( | archetype, | |
| string_index, | |||
| first_to_check ) |
Specifies printf/scanf-style format checking.
| archetype | "printf", "scanf", etc. |
| string_index | 1-based index of the format string. |
| first_to_check | 1-based index of first format argument. |
| #define FORMAT_ARG | ( | string_index | ) |
Applies format checking to a string-returning function.
| string_index | 1-based index of the format string argument. |
| #define MALLOC | ( | deallocator | ) |
Marks function as returning freshly allocated memory.
| deallocator | Optional deallocation function name. |
| #define NONNULL __attribute__((nonnull)) |
Marks all pointer arguments as non-null.
| #define NONNULL_POSITIONS | ( | ... | ) |
Marks specific pointer arguments as non-null.
| ... | List of 1-based parameter indices. |
| #define NORETURN __attribute__((noreturn)) |
Indicates a function never returns.
| #define NOTHROW __attribute__((nothrow)) |
Indicates the function does not throw exceptions.
| #define NULL_TERMINATED_STRING_ARG | ( | n | ) |
Marks a string argument as null-terminated.
| n | 1-based index of the parameter. |
| #define PURE __attribute__((pure)) |
Marks a function as having no side effects except return value.
| #define RETURN_NONNULL __attribute__((return_nonnull)) |
Declares that the function never returns a null pointer.
| #define SENTINEL __attribute__((sentinel)) |
Marks the last argument in a variadic function as a sentinel (e.g., NULL).
| #define UNAVAILABLE __attribute__((unavailable)) |
Marks a function or variable as unavailable.
| #define UNAVAILABLE_MSG | ( | msg | ) |
Marks a function or variable as unavailable, with a message.
| msg | Message shown on use. |
| #define UNREACHABLE __builtin_unreachable() |
Hints to the compiler that the following code is unreachable.
Used for optimization and to silence warnings about missing return paths.
| #define UNUSED __attribute__((unused)) |
Marks a variable or function as possibly unused to suppress warnings.
| #define USED __attribute__((used)) |
Marks a symbol to be emitted even if it appears unused.
| #define WARN_UNUSED_RESULT __attribute__((warn_unused_result)) |
Warns if the result of a function is ignored.
| #define WARNING | ( | msg | ) |
Triggers a compile-time warning if the function is used.
| msg | Warning message to display. |