Empirical
Macros
assert.h File Reference

A more dynamic replacement for standard library asserts. More...

#include <iostream>
#include <string>
#include <sstream>
#include "macros.h"

Go to the source code of this file.

Macros

#define emp_assert(...)
 
#define emp_emscripten_assert(...)   emp_assert(__VA_ARGS__)
 

Detailed Description

A more dynamic replacement for standard library asserts.

Note
This file is part of Empirical, https://github.com/devosoft/Empirical
Date
2016-2017
Note
Status: RELEASE

A replacement for the system-level assert.h, called "emp_assert" Added functionality:

Example:

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

When compiled in debug mode (i.e. without the -DNDEBUG flag), this will trigger an assertion error and print the value of a.

Todo:
: Add emp_assert_warning() for non-terminating assert. Should be able to disable with a command-line option (-DEMP_NO_WARNINGS)

Macro Definition Documentation

#define emp_assert (   ...)
Value:
do { \
!(EMP_GET_ARG_1(__VA_ARGS__, ~)) && \
emp::assert_trigger(__FILE__, __LINE__, EMP_WRAP_ARGS(emp_assert_TO_PAIR, __VA_ARGS__) ) && \
(abort(), false); \
} while(0)

Require a specified condition to be true. If it is false, immediately halt execution. Note: If NDEBUG is defined, emp_assert() will not do anything.

#define emp_emscripten_assert (   ...)    emp_assert(__VA_ARGS__)

Require a specified condition to be true if this program was compiled to Javascript with Emscripten. Note: If NDEBUG is defined, emp_emscripten_assert() will not do anything.