Flexible crash triggering and handling.
Macros | |
| #define | PW_ASSERT_HANDLE_FAILURE(condition_string) pw_assert_HandleFailure() |
| #define | PW_HANDLE_CRASH(...) |
| #define | PW_HANDLE_ASSERT_FAILURE(condition_string, ...) |
| #define | PW_HANDLE_ASSERT_BINARY_COMPARE_FAILURE(arg_a_str, arg_a_val, comparison_op_str, arg_b_str, arg_b_val, type_fmt, ...) |
| #define | PW_ASSERT(condition) |
| #define | PW_DASSERT(condition) |
| #define | PW_ASSERT_OK(expression, ...) |
| #define | PW_ASSERT_NOTNULL(ptr) |
| #define | PW_ASSERT_ENABLE_DEBUG 1 |
| #define | PW_ASSERT_CAPTURE_VALUES 1 |
| #define | PW_ASSERT_BASIC_ACTION_ABORT 100 |
| #define | PW_ASSERT_BASIC_ACTION_EXIT 101 |
| #define | PW_ASSERT_BASIC_ACTION_LOOP 102 |
| #define | PW_ASSERT_BASIC_ACTION PW_ASSERT_BASIC_ACTION_ABORT |
| #define | PW_ASSERT_BASIC_SHOW_BANNER 1 |
| Whether to show the CRASH ASCII art banner. | |
| #define | PW_ASSERT_BASIC_USE_COLORS 1 |
| Whether to use ANSI colors. | |
| #define | PW_CRASH(...) |
| #define | PW_CHECK(condition, ...) |
| #define | PW_DCHECK(...) |
| #define | PW_CHECK_INT_LE(arga, argb, ...) _PW_CHECK_BINARY_CMP_IMPL(arga, <=, argb, int, "%d", __VA_ARGS__) |
Asserts a <= b (int). | |
| #define | PW_CHECK_INT_LT(arga, argb, ...) _PW_CHECK_BINARY_CMP_IMPL(arga, < , argb, int, "%d", __VA_ARGS__) |
Asserts a < b (int). | |
| #define | PW_CHECK_INT_GE(arga, argb, ...) _PW_CHECK_BINARY_CMP_IMPL(arga, >=, argb, int, "%d", __VA_ARGS__) |
Asserts a >= b (int). | |
| #define | PW_CHECK_INT_GT(arga, argb, ...) _PW_CHECK_BINARY_CMP_IMPL(arga, > , argb, int, "%d", __VA_ARGS__) |
Asserts a > b (int). | |
| #define | PW_CHECK_INT_EQ(arga, argb, ...) _PW_CHECK_BINARY_CMP_IMPL(arga, ==, argb, int, "%d", __VA_ARGS__) |
Asserts a == b (int). | |
| #define | PW_CHECK_INT_NE(arga, argb, ...) _PW_CHECK_BINARY_CMP_IMPL(arga, !=, argb, int, "%d", __VA_ARGS__) |
Asserts a != b (int). | |
| #define | PW_DCHECK_INT_LE(...) if (!(PW_ASSERT_ENABLE_DEBUG)) {} else PW_CHECK_INT_LE(__VA_ARGS__) |
Debug check: asserts a <= b (int) when PW_ASSERT_ENABLE_DEBUG is enabled. | |
| #define | PW_DCHECK_INT_LT(...) if (!(PW_ASSERT_ENABLE_DEBUG)) {} else PW_CHECK_INT_LT(__VA_ARGS__) |
Debug check: asserts a < b (int) when PW_ASSERT_ENABLE_DEBUG is enabled. | |
| #define | PW_DCHECK_INT_GE(...) if (!(PW_ASSERT_ENABLE_DEBUG)) {} else PW_CHECK_INT_GE(__VA_ARGS__) |
Debug check: asserts a >= b (int) when PW_ASSERT_ENABLE_DEBUG is enabled. | |
| #define | PW_DCHECK_INT_GT(...) if (!(PW_ASSERT_ENABLE_DEBUG)) {} else PW_CHECK_INT_GT(__VA_ARGS__) |
Debug check: asserts a > b (int) when PW_ASSERT_ENABLE_DEBUG is enabled. | |
| #define | PW_DCHECK_INT_EQ(...) if (!(PW_ASSERT_ENABLE_DEBUG)) {} else PW_CHECK_INT_EQ(__VA_ARGS__) |
Debug check: asserts a == b (int) when PW_ASSERT_ENABLE_DEBUG is enabled. | |
| #define | PW_DCHECK_INT_NE(...) if (!(PW_ASSERT_ENABLE_DEBUG)) {} else PW_CHECK_INT_NE(__VA_ARGS__) |
Debug check: asserts a != b (int) when PW_ASSERT_ENABLE_DEBUG is enabled. | |
| #define | PW_CHECK_UINT_LE(arga, argb, ...) _PW_CHECK_BINARY_CMP_IMPL(arga, <=, argb, unsigned int, "%u", __VA_ARGS__) |
Asserts a <= b (unsigned int). | |
| #define | PW_CHECK_UINT_LT(arga, argb, ...) _PW_CHECK_BINARY_CMP_IMPL(arga, < , argb, unsigned int, "%u", __VA_ARGS__) |
Asserts a < b (unsigned int). | |
| #define | PW_CHECK_UINT_GE(arga, argb, ...) _PW_CHECK_BINARY_CMP_IMPL(arga, >=, argb, unsigned int, "%u", __VA_ARGS__) |
Asserts a >= b (unsigned int). | |
| #define | PW_CHECK_UINT_GT(arga, argb, ...) _PW_CHECK_BINARY_CMP_IMPL(arga, > , argb, unsigned int, "%u", __VA_ARGS__) |
Asserts a > b (unsigned int). | |
| #define | PW_CHECK_UINT_EQ(arga, argb, ...) _PW_CHECK_BINARY_CMP_IMPL(arga, ==, argb, unsigned int, "%u", __VA_ARGS__) |
Asserts a == b (unsigned int). | |
| #define | PW_CHECK_UINT_NE(arga, argb, ...) _PW_CHECK_BINARY_CMP_IMPL(arga, !=, argb, unsigned int, "%u", __VA_ARGS__) |
Asserts a != b (unsigned int). | |
| #define | PW_DCHECK_UINT_LE(...) if (!(PW_ASSERT_ENABLE_DEBUG)) {} else PW_CHECK_UINT_LE(__VA_ARGS__) |
Debug check: asserts a <= b (unsigned int) when PW_ASSERT_ENABLE_DEBUG is enabled. | |
| #define | PW_DCHECK_UINT_LT(...) if (!(PW_ASSERT_ENABLE_DEBUG)) {} else PW_CHECK_UINT_LT(__VA_ARGS__) |
Debug check: asserts a < b (unsigned int) when PW_ASSERT_ENABLE_DEBUG is enabled. | |
| #define | PW_DCHECK_UINT_GE(...) if (!(PW_ASSERT_ENABLE_DEBUG)) {} else PW_CHECK_UINT_GE(__VA_ARGS__) |
Debug check: asserts a >= b (unsigned int) when PW_ASSERT_ENABLE_DEBUG is enabled. | |
| #define | PW_DCHECK_UINT_GT(...) if (!(PW_ASSERT_ENABLE_DEBUG)) {} else PW_CHECK_UINT_GT(__VA_ARGS__) |
Debug check: asserts a > b (unsigned int) when PW_ASSERT_ENABLE_DEBUG is enabled. | |
| #define | PW_DCHECK_UINT_EQ(...) if (!(PW_ASSERT_ENABLE_DEBUG)) {} else PW_CHECK_UINT_EQ(__VA_ARGS__) |
Debug check: asserts a == b (unsigned int) when PW_ASSERT_ENABLE_DEBUG is enabled. | |
| #define | PW_DCHECK_UINT_NE(...) if (!(PW_ASSERT_ENABLE_DEBUG)) {} else PW_CHECK_UINT_NE(__VA_ARGS__) |
Debug check: asserts a != b (unsigned int) when PW_ASSERT_ENABLE_DEBUG is enabled. | |
| #define | PW_CHECK_PTR_LE(arga, argb, ...) _PW_CHECK_BINARY_CMP_IMPL(arga, <=, argb, const void*, "%p", __VA_ARGS__) |
Asserts a <= b (const void*). | |
| #define | PW_CHECK_PTR_LT(arga, argb, ...) _PW_CHECK_BINARY_CMP_IMPL(arga, < , argb, const void*, "%p", __VA_ARGS__) |
Asserts a < b (const void*). | |
| #define | PW_CHECK_PTR_GE(arga, argb, ...) _PW_CHECK_BINARY_CMP_IMPL(arga, >=, argb, const void*, "%p", __VA_ARGS__) |
Asserts a >= b (const void*). | |
| #define | PW_CHECK_PTR_GT(arga, argb, ...) _PW_CHECK_BINARY_CMP_IMPL(arga, > , argb, const void*, "%p", __VA_ARGS__) |
Asserts a > b (const void*). | |
| #define | PW_CHECK_PTR_EQ(arga, argb, ...) _PW_CHECK_BINARY_CMP_IMPL(arga, ==, argb, const void*, "%p", __VA_ARGS__) |
Asserts a == b (const void*). | |
| #define | PW_CHECK_PTR_NE(arga, argb, ...) _PW_CHECK_BINARY_CMP_IMPL(arga, !=, argb, const void*, "%p", __VA_ARGS__) |
Asserts a != b (const void*). | |
| #define | PW_CHECK_ADD(a, b, out, ...) |
| #define | PW_CHECK_SUB(a, b, out, ...) |
| #define | PW_CHECK_MUL(a, b, out, ...) |
| #define | PW_CHECK_NOTNULL(arga, ...) _PW_CHECK_BINARY_CMP_IMPL(arga, !=, nullptr, const void*, "%p", __VA_ARGS__) |
| #define | PW_DCHECK_PTR_LE(...) if (!(PW_ASSERT_ENABLE_DEBUG)) {} else PW_CHECK_PTR_LE(__VA_ARGS__) |
Debug check: asserts a <= b (const void*) when PW_ASSERT_ENABLE_DEBUG is enabled. | |
| #define | PW_DCHECK_PTR_LT(...) if (!(PW_ASSERT_ENABLE_DEBUG)) {} else PW_CHECK_PTR_LT(__VA_ARGS__) |
Debug check: asserts a < b (const void*) when PW_ASSERT_ENABLE_DEBUG is enabled. | |
| #define | PW_DCHECK_PTR_GE(...) if (!(PW_ASSERT_ENABLE_DEBUG)) {} else PW_CHECK_PTR_GE(__VA_ARGS__) |
Debug check: asserts a >= b (const void*) when PW_ASSERT_ENABLE_DEBUG is enabled. | |
| #define | PW_DCHECK_PTR_GT(...) if (!(PW_ASSERT_ENABLE_DEBUG)) {} else PW_CHECK_PTR_GT(__VA_ARGS__) |
Debug check: asserts a > b (const void*) when PW_ASSERT_ENABLE_DEBUG is enabled. | |
| #define | PW_DCHECK_PTR_EQ(...) if (!(PW_ASSERT_ENABLE_DEBUG)) {} else PW_CHECK_PTR_EQ(__VA_ARGS__) |
Debug check: asserts a == b (const void*) when PW_ASSERT_ENABLE_DEBUG is enabled. | |
| #define | PW_DCHECK_PTR_NE(...) if (!(PW_ASSERT_ENABLE_DEBUG)) {} else PW_CHECK_PTR_NE(__VA_ARGS__) |
Debug check: asserts a != b (const void*) when PW_ASSERT_ENABLE_DEBUG is enabled. | |
| #define | PW_DCHECK_NOTNULL(...) if (!(PW_ASSERT_ENABLE_DEBUG)) {} else PW_CHECK_NOTNULL(__VA_ARGS__) |
Debug variant of PW_CHECK_NOTNULL that only runs if PW_ASSERT_ENABLE_DEBUG is enabled. | |
| #define | PW_CHECK_FLOAT_NEAR(arga, argb, abs_tolerance, ...) _PW_CHECK_FLOAT_NEAR(arga, argb, abs_tolerance, __VA_ARGS__) |
| #define | PW_CHECK_FLOAT_EXACT_LE(arga, argb, ...) _PW_CHECK_BINARY_CMP_IMPL(arga, <=, argb, float, "%f", __VA_ARGS__) |
Asserts a <= b (float). | |
| #define | PW_CHECK_FLOAT_EXACT_LT(arga, argb, ...) _PW_CHECK_BINARY_CMP_IMPL(arga, < , argb, float, "%f", __VA_ARGS__) |
Asserts a < b (float). | |
| #define | PW_CHECK_FLOAT_EXACT_GE(arga, argb, ...) _PW_CHECK_BINARY_CMP_IMPL(arga, >=, argb, float, "%f", __VA_ARGS__) |
Asserts a >= b (float). | |
| #define | PW_CHECK_FLOAT_EXACT_GT(arga, argb, ...) _PW_CHECK_BINARY_CMP_IMPL(arga, > , argb, float, "%f", __VA_ARGS__) |
Asserts a > b (float). | |
| #define | PW_CHECK_FLOAT_EXACT_EQ(arga, argb, ...) _PW_CHECK_BINARY_CMP_IMPL(arga, ==, argb, float, "%f", __VA_ARGS__) |
Asserts a == b (float). | |
| #define | PW_CHECK_FLOAT_EXACT_NE(arga, argb, ...) _PW_CHECK_BINARY_CMP_IMPL(arga, !=, argb, float, "%f", __VA_ARGS__) |
Asserts a != b (float). | |
| #define | PW_DCHECK_FLOAT_NEAR(...) if (!(PW_ASSERT_ENABLE_DEBUG)) {} else PW_CHECK_FLOAT_NEAR(__VA_ARGS__) |
Debug variant of PW_CHECK_FLOAT_NEAR that only runs if PW_ASSERT_ENABLE_DEBUG is enabled. | |
| #define | PW_DCHECK_FLOAT_EXACT_LE(...) if (!(PW_ASSERT_ENABLE_DEBUG)) {} else PW_CHECK_FLOAT_EXACT_LE(__VA_ARGS__) |
Debug check: asserts a <= b (float) when PW_ASSERT_ENABLE_DEBUG is enabled. | |
| #define | PW_DCHECK_FLOAT_EXACT_LT(...) if (!(PW_ASSERT_ENABLE_DEBUG)) {} else PW_CHECK_FLOAT_EXACT_LT(__VA_ARGS__) |
Debug check: asserts a < b (float) when PW_ASSERT_ENABLE_DEBUG is enabled. | |
| #define | PW_DCHECK_FLOAT_EXACT_GE(...) if (!(PW_ASSERT_ENABLE_DEBUG)) {} else PW_CHECK_FLOAT_EXACT_GE(__VA_ARGS__) |
Debug check: asserts a >= b (float) when PW_ASSERT_ENABLE_DEBUG is enabled. | |
| #define | PW_DCHECK_FLOAT_EXACT_GT(...) if (!(PW_ASSERT_ENABLE_DEBUG)) {} else PW_CHECK_FLOAT_EXACT_GT(__VA_ARGS__) |
Debug check: asserts a > b (float) when PW_ASSERT_ENABLE_DEBUG is enabled. | |
| #define | PW_DCHECK_FLOAT_EXACT_EQ(...) if (!(PW_ASSERT_ENABLE_DEBUG)) {} else PW_CHECK_FLOAT_EXACT_EQ(__VA_ARGS__) |
Debug check: asserts a == b (float) when PW_ASSERT_ENABLE_DEBUG is enabled. | |
| #define | PW_DCHECK_FLOAT_EXACT_NE(...) if (!(PW_ASSERT_ENABLE_DEBUG)) {} else PW_CHECK_FLOAT_EXACT_NE(__VA_ARGS__) |
Debug check: asserts a != b (float) when PW_ASSERT_ENABLE_DEBUG is enabled. | |
| #define | PW_CHECK_OK(expression, ...) |
| #define | _PW_CHECK_OK_STATUS auto |
| #define | _PW_CHECK_OK_TO_STATUS(expr) ::pw::internal::ConvertToStatus(expr) |
| #define | _PW_CHECK_OK_IS_OK(status) (status).ok() |
| #define | _PW_CHECK_OK_STATUS_STRING(status) ::pw::internal::StatusToCheckString(status) |
| #define | PW_DCHECK_OK(...) |
| #define | CRASH PW_CRASH |
| #define | CHECK PW_CHECK |
| #define | CHECK_PTR_LE PW_CHECK_PTR_LE |
| #define | CHECK_PTR_LT PW_CHECK_PTR_LT |
| #define | CHECK_PTR_GE PW_CHECK_PTR_GE |
| #define | CHECK_PTR_GT PW_CHECK_PTR_GT |
| #define | CHECK_PTR_EQ PW_CHECK_PTR_EQ |
| #define | CHECK_PTR_NE PW_CHECK_PTR_NE |
| #define | CHECK_NOTNULL PW_CHECK_NOTNULL |
| #define | CHECK_INT_LE PW_CHECK_INT_LE |
| #define | CHECK_INT_LT PW_CHECK_INT_LT |
| #define | CHECK_INT_GE PW_CHECK_INT_GE |
| #define | CHECK_INT_GT PW_CHECK_INT_GT |
| #define | CHECK_INT_EQ PW_CHECK_INT_EQ |
| #define | CHECK_INT_NE PW_CHECK_INT_NE |
| #define | CHECK_UINT_LE PW_CHECK_UINT_LE |
| #define | CHECK_UINT_LT PW_CHECK_UINT_LT |
| #define | CHECK_UINT_GE PW_CHECK_UINT_GE |
| #define | CHECK_UINT_GT PW_CHECK_UINT_GT |
| #define | CHECK_UINT_EQ PW_CHECK_UINT_EQ |
| #define | CHECK_UINT_NE PW_CHECK_UINT_NE |
| #define | CHECK_FLOAT_NEAR PW_CHECK_FLOAT_NEAR |
| #define | CHECK_FLOAT_EXACT_LE PW_CHECK_FLOAT_EXACT_LE |
| #define | CHECK_FLOAT_EXACT_LT PW_CHECK_FLOAT_EXACT_LT |
| #define | CHECK_FLOAT_EXACT_GE PW_CHECK_FLOAT_EXACT_GE |
| #define | CHECK_FLOAT_EXACT_GT PW_CHECK_FLOAT_EXACT_GT |
| #define | CHECK_FLOAT_EXACT_EQ PW_CHECK_FLOAT_EXACT_EQ |
| #define | CHECK_FLOAT_EXACT_NE PW_CHECK_FLOAT_EXACT_NE |
| #define | CHECK_OK PW_CHECK_OK |
| #define | DCHECK PW_DCHECK |
| #define | DCHECK_PTR_LE PW_DCHECK_PTR_LE |
| #define | DCHECK_PTR_LT PW_DCHECK_PTR_LT |
| #define | DCHECK_PTR_GE PW_DCHECK_PTR_GE |
| #define | DCHECK_PTR_GT PW_DCHECK_PTR_GT |
| #define | DCHECK_PTR_EQ PW_DCHECK_PTR_EQ |
| #define | DCHECK_PTR_NE PW_DCHECK_PTR_NE |
| #define | DCHECK_NOTNULL PW_DCHECK_NOTNULL |
| #define | DCHECK_INT_LE PW_DCHECK_INT_LE |
| #define | DCHECK_INT_LT PW_DCHECK_INT_LT |
| #define | DCHECK_INT_GE PW_DCHECK_INT_GE |
| #define | DCHECK_INT_GT PW_DCHECK_INT_GT |
| #define | DCHECK_INT_EQ PW_DCHECK_INT_EQ |
| #define | DCHECK_INT_NE PW_DCHECK_INT_NE |
| #define | DCHECK_UINT_LE PW_DCHECK_UINT_LE |
| #define | DCHECK_UINT_LT PW_DCHECK_UINT_LT |
| #define | DCHECK_UINT_GE PW_DCHECK_UINT_GE |
| #define | DCHECK_UINT_GT PW_DCHECK_UINT_GT |
| #define | DCHECK_UINT_EQ PW_DCHECK_UINT_EQ |
| #define | DCHECK_UINT_NE PW_DCHECK_UINT_NE |
| #define | DCHECK_FLOAT_NEAR PW_DCHECK_FLOAT_NEAR |
| #define | DCHECK_FLOAT_EXACT_LT PW_DCHECK_FLOAT_EXACT_LT |
| #define | DCHECK_FLOAT_EXACT_LE PW_DCHECK_FLOAT_EXACT_LE |
| #define | DCHECK_FLOAT_EXACT_GT PW_DCHECK_FLOAT_EXACT_GT |
| #define | DCHECK_FLOAT_EXACT_GE PW_DCHECK_FLOAT_EXACT_GE |
| #define | DCHECK_FLOAT_EXACT_EQ PW_DCHECK_FLOAT_EXACT_EQ |
| #define | DCHECK_FLOAT_EXACT_NE PW_DCHECK_FLOAT_EXACT_NE |
| #define | DCHECK_OK PW_DCHECK_OK |
Functions | |
| PW_NO_RETURN void | pw_assert_HandleFailure (void) |
| #define PW_ASSERT | ( | condition | ) |
A header- and constexpr-safe version of PW_CHECK().
If the given condition is false, crash the system. Otherwise, do nothing. The condition is guaranteed to be evaluated. This assert implementation is guaranteed to be constexpr-safe.
PW_CHECK_*() suite of macros, not all backends for this API capture rich information like line numbers, the file, expression arguments, or the stringified expression. Use these macros only when absolutely necessary — in headers, constexpr contexts, or in rare cases where the call site overhead of a full PW_CHECK must be avoided. Use PW_CHECK_*() whenever possible. | #define PW_ASSERT_BASIC_ACTION PW_ASSERT_BASIC_ACTION_ABORT |
Set to one of the following to define how pw_assert_basic should act after an assert failure:
PW_ASSERT_BASIC_ACTION_ABORT: Call std::abort()PW_ASSERT_BASIC_ACTION_EXIT: Call std::_Exit(-1)PW_ASSERT_BASIC_ACTION_LOOP: Loop forever | #define PW_ASSERT_CAPTURE_VALUES 1 |
Controls whether the evaluated values of a CHECK statement are captured as arguments to the final string. Disabling this will reduce code size at CHECK callsites, but slightly reduces debuggability.
This defaults to enabled.
| #define PW_ASSERT_ENABLE_DEBUG 1 |
Controls whether DCHECK and DASSERT are enabled.
This defaults to being disabled if NDEBUG is defined, else it is enabled by default.
| #define PW_ASSERT_HANDLE_FAILURE | ( | condition_string | ) | pw_assert_HandleFailure() |
Handles a low-level crash from pw_assert/assert.h. Backends must ensure their implementation is safe for usage in headers, constexpr contexts, and templates. This macro should expand to an expression that does not return.
| #define PW_ASSERT_NOTNULL | ( | ptr | ) |
A header- and constexpr-safe version of PW_CHECK_NOTNULL().
If the given pointer is nullptr, crash the system. Otherwise, return the pointer unchanged. The expression is guaranteed to be evaluated once.
In C++, ptr may be a raw pointer, function pointer, or smart pointer (any type comparable to nullptr). The argument's type and value category are preserved, making it suitable for initializing member variables in constructor initializer lists. This macro is only available in C++.
PW_CHECK_*() suite of macros, not all backends for this API capture rich information like line numbers, the file, expression arguments, or the stringified expression. Use these macros only when absolutely necessary — in headers, constexpr contexts, or in rare cases where the call site overhead of a full PW_CHECK must be avoided. Use PW_CHECK_*() whenever possible. | #define PW_ASSERT_OK | ( | expression, | |
| ... | |||
| ) |
A header- and constexpr-safe version of PW_CHECK_OK().
If expression does not evaluate to an OK status, crash. Otherwise, do nothing. The expression is guaranteed to be evaluated.
In C++, expression must evaluate to a value convertible to a status via pw::internal::ConvertToStatus(). This includes pw::Status, pw_Status, pw::StatusWithSize, pw::Result, and custom pw::StatusBase-derived types.
In C, expression must evaluate to a pw_Status value.
Unlike PW_CHECK_OK, this macro does not currently log the failed status kind.
PW_CHECK_*() suite of macros, not all backends for this API capture rich information like line numbers, the file, expression arguments, or the stringified expression. Use these macros only when absolutely necessary — in headers, constexpr contexts, or in rare cases where the call site overhead of a full PW_CHECK must be avoided. Use PW_CHECK_*() whenever possible. | #define PW_CHECK | ( | condition, | |
| ... | |||
| ) |
Asserts that a condition is true, optionally including a message with arguments to report if the condition is false.
Overloads:
| #define PW_CHECK_ADD | ( | a, | |
| b, | |||
| out, | |||
| ... | |||
| ) |
| #define PW_CHECK_FLOAT_NEAR | ( | arga, | |
| argb, | |||
| abs_tolerance, | |||
| ... | |||
| ) | _PW_CHECK_FLOAT_NEAR(arga, argb, abs_tolerance, __VA_ARGS__) |
Asserts that (a >= b - abs_tolerance) && (a <= b + abs_tolerance) is true, where a, b, and abs_tolerance are converted to float. Also asserts that abs_tolerance >= 0.
Overloads:
| #define PW_CHECK_MUL | ( | a, | |
| b, | |||
| out, | |||
| ... | |||
| ) |
| #define PW_CHECK_NOTNULL | ( | arga, | |
| ... | |||
| ) | _PW_CHECK_BINARY_CMP_IMPL(arga, !=, nullptr, const void*, "%p", __VA_ARGS__) |
Asserts that the given pointer is not NULL (nullptr in C++), optionally including a message with arguments to report if the pointer is NULL.
Overloads:
| #define PW_CHECK_OK | ( | expression, | |
| ... | |||
| ) |
Asserts that expression evaluates to pw::OkStatus() (in C++) or PW_STATUS_OK (in C). Optionally includes a message with arguments to report.
In C++, expression must evaluate to a value convertible to a status via pw::internal::ConvertToStatus(). This includes pw::Status, pw_Status, pw::StatusWithSize, pw::Result, and custom pw::StatusBase-derived types.
In C, expression must evaluate to a pw_Status value.
Overloads:
| #define PW_CHECK_SUB | ( | a, | |
| b, | |||
| out, | |||
| ... | |||
| ) |
| #define PW_CRASH | ( | ... | ) |
Triggers a crash with a message. Replaces LOG_FATAL() in other systems. Can include a message with format arguments; for example:
| #define PW_DASSERT | ( | condition | ) |
A header- and constexpr-safe version of PW_DCHECK().
Same as PW_ASSERT(), except that if PW_ASSERT_ENABLE_DEBUG == 0, the assert is disabled and condition is not evaluated.
PW_CHECK_*() suite of macros, not all backends for this API capture rich information like line numbers, the file, expression arguments, or the stringified expression. Use these macros only when absolutely necessary — in headers, constexpr contexts, or in rare cases where the call site overhead of a full PW_CHECK must be avoided. Use PW_CHECK_*() whenever possible. | #define PW_DCHECK | ( | ... | ) |
Debug variant of PW_CHECK that only runs if PW_ASSERT_ENABLE_DEBUG is enabled; otherwise, the entire statement is removed (and the expression not evaluated).
Overloads:
| #define PW_DCHECK_OK | ( | ... | ) |
Debug variant of PW_CHECK_OK that only runs if PW_ASSERT_ENABLE_DEBUG is enabled.
Overloads:
| #define PW_HANDLE_ASSERT_BINARY_COMPARE_FAILURE | ( | arg_a_str, | |
| arg_a_val, | |||
| comparison_op_str, | |||
| arg_b_str, | |||
| arg_b_val, | |||
| type_fmt, | |||
| ... | |||
| ) |
Triggers a system crash or halt for a failed binary comparison assert (e.g. any of the PW_CHECK_<type>_<op> macros). The handler should combine the assert components into a useful message for the user; though in some cases this may not be possible.
arg_a_str - Stringified first operand.arg_a_val - The value of the first operand.comparison_op_str - The string version of the operator.arg_b_str - Stringified second operand.arg_b_val - The value of the second operand.type_fmt - The format code for the type.... - A formatted message and arguments to go with the assert. | #define PW_HANDLE_ASSERT_FAILURE | ( | condition_string, | |
| ... | |||
| ) |
Triggers a system crash or halt, and if possible, delivers the condition string (indicating what expression was false) and the message with format arguments, to the user or developer.
This macro is invoked from the PW_CHECK facade macro if condition is false.
| #define PW_HANDLE_CRASH | ( | ... | ) |
Triggers a system crash or halt, and if possible, delivers the specified message and arguments to the user or developer.
| PW_NO_RETURN void pw_assert_HandleFailure | ( | void | ) |
Handles a low-level crash from pw_assert/assert.h. In this crash handler, there is no access to line, file, expression, or other rich assert information. Must not return.