OTCLIB_ASSERT - macro to aid in program verfication

SYNOPSIS

#include <OTC/OTC.h>

OTCLIB_ASSERT(expression);

DESCRIPTION

The macro OTCLIB_ASSERT() can be used to aid in program verification. The macro is used to indicate the expectation that the expression is to be true at this point in the program. If the expression is false, an exception of type OTCERR_AssertionFailure is thrown. Compiling with the compiler option -DNDEBUG effectively deletes OTCLIB_ASSERT() from the program. If you are using makeit, the NDEBUG symbol is automatically defined when you use the opt variant. Note that the expression evaluated in the condition, should not produce any side effects, which the program relies upon. If this is done, when the assertions are compiled out of code, the program may stop functioning correctly.

EXAMPLES

OTCLIB_ASSERT(TRUE == FALSE);

FORMAT

If the exception is caught and the information it contains is dumped to the logger, the format of the output will be:

ERROR: Assertion failed
ERROR: Location: "_assert.cc", line 33
ERROR: Condition: TRUE == FALSE

NOTES

The macro may be used in either C or C++ code.

A string literal should not be used as part of the condition as some preprocessors cannot handle converting to a string, a value which has a string in it.

SEE ALSO

OTCERR_AssertionFailure, OTC_Logger