Asserts.h file
Assertions and event tracing.
Most functions and macros for event tracing require DEATH_TRACE to be defined. Otherwise, no operation is performed. In addition, assert statements can be suppressed with DEATH_NO_ASSERT define or redirected to the standard assert() with DEATH_STANDARD_ASSERT define. See also Death::
Enums
Functions
-
void DEATH_TRACE(TraceLevel level,
const char* functionName,
const char* message,
std::
uint32_t messageLength) - Callback function for writing to the event log.
Defines
- #define LOGD(fmt, ...)
- Write a formatted message with TraceLevel::
Debug to the event log. - #define LOGB(fmt, ...)
- Write a deferred formatted message with TraceLevel::
Deferred to the event log. - #define LOGI(fmt, ...)
- Write a formatted message with TraceLevel::
Info to the event log. - #define LOGW(fmt, ...)
- Write a formatted message with TraceLevel::
Warning to the event log. - #define LOGE(fmt, ...)
- Write a formatted message with TraceLevel::
Error to the event log. - #define LOGF(fmt, ...)
- Write a formatted message with TraceLevel::
Fatal to the event log. - #define DEATH_ASSERT_BREAK()
- Break the execution if
DEATH_DEBUGis defined. - #define DEATH_ASSERT(condition, ...)
- Assertion macro.
- #define DEATH_DEBUG_ASSERT(condition, ...)
- Debug-only assertion macro.
- #define DEATH_CONSTEXPR_ASSERT(condition, message)
- Constexpr assertion macro.
- #define DEATH_DEBUG_CONSTEXPR_ASSERT(condition, message)
- Debug-only constexpr assertion macro.
- #define DEATH_ASSERT_UNREACHABLE(...)
- Assert that the code is unreachable.
Enum documentation
Function documentation
void DEATH_TRACE(TraceLevel level,
const char* functionName,
const char* message,
std:: uint32_t messageLength)
Callback function for writing to the event log.
This function needs to be provided by the target application to enable the event tracing. Alternatively, ITraceSink interface can be used instead.
Define documentation
#define DEATH_ASSERT(condition, ...)
Assertion macro.
Usable for sanity checks on user input, as it prints explanational message on error.
By default, if assertion fails, message is printed with TraceLevel::returnValue instead and the execution is break (if DEATH_DEBUG is defined). If DEATH_STANDARD_ASSERT is defined, this macro expands to assert(condition), ignoring message. If DEATH_NO_ASSERT is defined (or if both DEATH_TRACE and DEATH_STANDARD_ASSERT are not defined), this macro expands to do{}while(false). It also allows to specify only the condition, and the message will be generated automatically without return statement.
You can override this implementation by placing your own #define DEATH_ASSERT before including the Asserts.h header.
#define DEATH_DEBUG_ASSERT(condition, ...)
Debug-only assertion macro.
Unlike DEATH_do{}while(false) if DEATH_DEBUG is not defined (i.e., in release configuration). It also allows to specify only the condition, and the message will be generated automatically without return statement.
You can override this implementation by placing your own #define DEATH_DEBUG_ASSERT before including the Asserts.h header.
#define DEATH_CONSTEXPR_ASSERT(condition, message)
Constexpr assertion macro.
Unlike DEATH_constexpr functions. In a constexpr context, if assertion fails, the code fails to compile. In a non- constexpr context, if assertion fails, message is printed with TraceLevel::DEATH_STANDARD_ASSERT is defined, message is ignored and the standard assert() is called if condition fails. If DEATH_NO_ASSERT is defined (or if both DEATH_TRACE and DEATH_STANDARD_ASSERT are not defined), this macro expands to static_cast<void>(0).
You can override this implementation by placing your own #define DEATH_CONSTEXPR_ASSERT before including the Asserts.h header.
#define DEATH_DEBUG_CONSTEXPR_ASSERT(condition, message)
Debug-only constexpr assertion macro.
Unlike DEATH_static_cast<void>(0) if DEATH_DEBUG is not defined (i.e., in release configuration).
You can override this implementation by placing your own #define DEATH_DEBUG_CONSTEXPR_ASSERT before including the Asserts.h header.
#define DEATH_ASSERT_UNREACHABLE(...)
Assert that the code is unreachable.
By default, if code marked with this macro is reached, a hint message is printed with TraceLevel::DEATH_DEBUG is defined). If DEATH_STANDARD_ASSERT is defined, the standard assert(!"Unreachable code") is called. If DEATH_NO_ASSERT is defined (or if both DEATH_TRACE and DEATH_STANDARD_ASSERT are not defined), this macro hints to the compiler that given code is not reachable, possibly helping the optimizer (using a compiler builtin on GCC, Clang and MSVC; calling std::
You can override this implementation by placing your own #define DEATH_ASSERT_UNREACHABLE before including the Asserts.h header.