assert.h¶
Static assertions.
For the sake of convenience, this header automatically includes metalang99/bool.h
.
Note
[C99] Any of the following assertion macros must not appear on the same line number twice with itself as well as with any other Metalang99 assertion macro.
Note
[C11] The following assertion macros expand to _Static_assert
and, therefore, can be used on the same line twice.
Defines
-
ML99_assert(expr)¶
The same as ML99_ASSERT but results in a Metalang99 term.
It can be used inside other Metalang99-compliant macros, unlike ML99_ASSERT, which uses ML99_EVAL internally.
-
ML99_assertEq(lhs, rhs)¶
Like ML99_assert but compares
lhs
withrhs
for equality (==
).
-
ML99_ASSERT(expr)¶
Asserts
ML99_EVAL(expr)
at compile-time.Examples
#include <metalang99/assert.h> ML99_ASSERT(v(123 == 123));
-
ML99_ASSERT_EQ(lhs, rhs)¶
Asserts
ML99_EVAL(lhs) == ML99_EVAL(rhs)
at compile-time.Examples
#include <metalang99/assert.h> ML99_ASSERT_EQ(v(123), v(123));
-
ML99_ASSERT_UNEVAL(expr)¶
Asserts the C constant expression
expr
; static_assert in pure C99.Examples
#include <metalang99/assert.h> ML99_ASSERT_UNEVAL(123 == 123);
-
ML99_ASSERT_EMPTY(expr)¶
Asserts that
ML99_EVAL(expr)
is emptiness.Examples
#include <metalang99/assert.h> // Passes: ML99_ASSERT_EMPTY(v()); // Fails: ML99_ASSERT_EMPTY(v(123));
-
ML99_ASSERT_EMPTY_UNEVAL(expr)¶
Asserts that
expr
is emptiness.Examples
#include <metalang99/assert.h> // Passes: ML99_ASSERT_EMPTY_UNEVAL(); // Fails: ML99_ASSERT_EMPTY_UNEVAL(123);