always_assert_warning.hpp

A more dynamic replacement for standard library asserts.

This file is part of Empirical, https://github.com/devosoft/Empirical Copyright (C) 2023 Michigan State University MIT Software license; see doc/LICENSE.md

A replacement for the system-level assert.h, called “emp_always_assert” Added functionality:

  • If compiled with Emscripten, will provide pop-up alerts in a web browser.

  • emp_assert can take additional arguments. If the assert is triggered, those extra arguments will be evaluated and printed.

  • if EMP_TDEBUG is defined, emp_assert() goes into test mode and records failures, but does not abort. (useful for unit tests of asserts)

Example:

int a = 6; emp_always_assert(a==5, a);

Unlike “emp_assert_warning”, “emp_always_assert_warning” will trigger an assertion error whether compiled in debug mode or not.

Note

Status: RELEASE

Defines

INCLUDE_EMP_BASE_ALWAYS_ASSERT_WARNING_HPP_GUARD
emp_always_assert_warning_impl(...)
emp_always_assert_warning(...)

Require a specified condition to be true. If it is false, immediately halt execution. Print also extra information on any variables or expressions provided as variadic args. Will be evaluated when compiled in both debug and release mode. Can be disabled with -DEMP_NO_WARNINGS.