Assertion utils

group Assertion helpers

Utilities for performing assertions

Defines

a_static_assert_expr(expr, msg)

Helper for using _Static_assert in expressions

_Static_assert is not an expression according to the C standard, so embedding it in macros used for assignment is not directly possible. This trickery gets around that problem.

Parameters:
  • expr – The assertion expression

  • msg – The message to display during compilation if the assertion failed

a_assert_or_expression(condition, msg, expression)

Execute an expression if assertion passes

Assertion helper to enable _Static_assert usage in macros that are used to assign in constexpr context.

Parameters:
  • condition – A constexpr condition that evaluates to non-0 for “pass” and 0 for “fail”

  • msg – The error message to present if the condition fails

  • expression – The expression to execute if the condition passes

Returns:

Whatever expression returns