NAME
NO_SANITIZE_ALIGNMENT,
NO_SANITIZE_UNDEFINED,
NO_SANITIZE_SIGNED_INTEGER_OVERFLOW,
NO_SANITIZE_UNSIGNED_INTEGER_OVERFLOW,
FALLTHROUGH, UNUSED,
NDEBUG_UNUSED, FP,
STATIC_ASSERT, UNSAFE_CAST,
countof —
compiler macros
SYNOPSIS
#include
<libks/compiler.h>
__attribute__((NO_SANITIZE_ALIGNMENT))
__attribute__((NO_SANITIZE_UNDEFINED))
__attribute__((NO_SANITIZE_SIGNED_INTEGER_OVERFLOW))
__attribute__((NO_SANITIZE_UNSIGNED_INTEGER_OVERFLOW))
FALLTHROUGH;
UNUSED(variable);
NDEBUG_UNUSED(variable);
FP(invariant,
...);
STATIC_ASSERT(expression,
message);
UNSAFE_CAST(type,
variable);
countof(variable);
DESCRIPTION
The compiler macros can be used to instruct the compiler about certain properties of the source code.
The NO_SANITIZE_ALIGNMENT macro is
intended to be used as an __attribute__ argument applicable to functions,
instructing the compiler to omit the alignment sanitizer.
The NO_SANITIZE_UNDEFINED macro is
intended to be used as an __attribute__ argument applicable to functions,
instructing the compiler to omit the undefined behavior sanitizer.
The NO_SANITIZE_SIGNED_INTEGER_OVERFLOW
macro is intended to be used as an __attribute__ argument applicable to
functions, instructing the compiler to omit the signed integer overflow
sanitizer.
The NO_SANITIZE_UNSIGNED_INTEGER_OVERFLOW
macro is intended to be used as an __attribute__ argument applicable to
functions, instructing the compiler to omit the unsigned integer overflow
sanitizer.
The FALLTHROUGH macro annotates a switch
case as intentionally continuing execution to the next case.
The
UNUSED()
macro annotates variable as being unused.
The
NDEBUG_UNUSED()
macro annotates variable as being unused if
NDEBUG is defined.
The
FP() macro
mitigates static analyzer false positives by making the
invariant observable. One or more annotations may be
supplied which are discarded. Expands to nothing if
NDEBUG is defined.
FP(ptr != NULL, cppcheck, nullPointer);
The
STATIC_ASSERT()
macro ensures expression evaluates non-zero at compile
time.
The
UNSAFE_CAST()
macro performs an unsafe cast, tricking the compiler into not emitting a
warning or error.
The
countof()
macro returns the number of elements in variable which
is required to be an array.
AUTHORS
Anton Lindqvist <anton@basename.se>