Files | |
file | assert.h |
Extended assertion handling. | |
file | error.h |
Basic exception classes and error handling. | |
Classes | |
class | Exception |
Generic exception class. More... | |
class | IoError |
Input-Output error. More... | |
class | FormatError |
Format error. More... | |
Defines | |
#define | LEMON_ASSERT(exp, msg) |
Macro for assertion with customizable message. | |
#define | LEMON_DEBUG(exp, msg) |
Macro for internal assertions. |
#define LEMON_ASSERT | ( | exp, | |||
msg | ) |
Value:
(static_cast<void> (!!(exp) ? 0 : ( \ LEMON_ASSERT_HANDLER(__FILE__, __LINE__, \ LEMON_FUNCTION_NAME, \ ::lemon::_assert_bits::cstringify(msg), #exp), 0)))
exp | An expression that must be convertible to bool . If it is false , then an assertion is raised. The concrete behaviour depends on the settings of the assertion system. | |
msg | A const char* parameter, which can be used to provide information about the circumstances of the failed assertion. |
#define LEMON_DISABLE_ASSERTS
g++ -DLEMON_DISABLE_ASSERTS
make CXXFLAGS='-DLEMON_DISABLE_ASSERTS'
NDEBUG
is defined.As a default behaviour the failed assertion prints a short log message to the standard error and aborts the execution.
However, the following modes can be used in the assertion system:
LEMON_ASSERT_ABORT
The failed assertion prints a short log message to the standard error and aborts the program. It is the default behaviour.LEMON_ASSERT_CUSTOM
The user can define own assertion handler function. void custom_assert_handler(const char* file, int line, const char* function, const char* message, const char* assertion);
LEMON_CUSTOM_ASSERT_HANDLER
macro name. #define LEMON_CUSTOM_ASSERT_HANDLER custom_assert_handler
The assertion mode can also be changed within one compilation unit. If the macros are redefined with other settings and the assert.h file is reincluded, then the behaviour is changed appropiately to the new settings.
#define LEMON_DEBUG | ( | exp, | |||
msg | ) |
Value:
(static_cast<void> (!!(exp) ? 0 : ( \ LEMON_ASSERT_HANDLER(__FILE__, __LINE__, \ LEMON_FUNCTION_NAME, \ ::lemon::_assert_bits::cstringify(msg), #exp), 0)))
LEMON_ENABLE_DEBUG
. #define LEMON_ENABLE_DEBUG
g++ -DLEMON_ENABLE_DEBUG
make CXXFLAGS='-DLEMON_ENABLE_DEBUG'
This macro works like the LEMON_ASSERT
macro, therefore the current behaviour depends on the settings of LEMON_ASSERT
macro.