Loading...
Searching...
No Matches
assert.h
Go to the documentation of this file.
#ifndef ML99_ASSERT_H
#define ML99_ASSERT_H
#include <metalang99/priv/compiler_specific.h>
#include <metalang99/bool.h>
#include <metalang99/lang.h>
#define ML99_assert(expr) ML99_call(ML99_assert, expr)
#define ML99_assertEq(lhs, rhs) ML99_call(ML99_assertEq, lhs, rhs)
#define ML99_ASSERT(expr) ML99_ASSERT_EQ(expr, ML99_true())
#define ML99_ASSERT_EQ(lhs, rhs) ML99_ASSERT_UNEVAL((ML99_EVAL(lhs)) == (ML99_EVAL(rhs)))
#define ML99_ASSERT_UNEVAL(expr) ML99_PRIV_ASSERT_UNEVAL_INNER(expr)
#define ML99_ASSERT_EMPTY(expr) ML99_ASSERT_EMPTY_UNEVAL(ML99_EVAL(expr))
#define ML99_ASSERT_EMPTY_UNEVAL(expr) \
ML99_ASSERT_UNEVAL(ML99_PRIV_CAT(ML99_PRIV_ASSERT_EMPTY_, expr))
#ifndef DOXYGEN_IGNORE
#define ML99_assert_IMPL(expr) v(ML99_ASSERT_UNEVAL(expr))
#define ML99_assertEq_IMPL(lhs, rhs) v(ML99_ASSERT_UNEVAL((lhs) == (rhs)))
#ifdef ML99_PRIV_C11_STATIC_ASSERT_AVAILABLE
#define ML99_PRIV_ASSERT_UNEVAL_INNER(expr) _Static_assert((expr), "Metalang99 assertion failed")
#else
// How to imitate static assertions in C99: <https://stackoverflow.com/a/3385694/13166656>.
#define ML99_PRIV_ASSERT_UNEVAL_INNER(expr) \
static const char ML99_PRIV_CAT( \
ml99_assert_, \
__LINE__)[(expr) ? 1 : -1] ML99_PRIV_COMPILER_ATTR_UNUSED = {0}
#endif
#define ML99_PRIV_ASSERT_EMPTY_ 1
// Arity specifiers {
#define ML99_assert_ARITY 1
#define ML99_assertEq_ARITY 2
// } (Arity specifiers)
#endif // DOXYGEN_IGNORE
#endif // ML99_ASSERT_H
bool.h
Boolean algebra.
lang.h
The core metalanguage.