CppELib 1.7.0
|
#include <cstddef>
Go to the source code of this file.
Classes | |
class | Assertion::AssertHandler |
Interface for handling assertion failure by CHECK_ASSERT() macro. More... | |
class | Assertion::Failure |
Class used when CHECK_ASSERT() macro fails. More... | |
Namespaces | |
namespace | Assertion |
Macros | |
#define | CPPELIB_ASSERTION_FAILURE_BUFSIZE (512) |
Buffer size of Assertion::Failure object. | |
#define | CHECK_ASSERT(x) ((x) ? (void)0 : Assertion::Failure::assertFail(__FILE__, __LINE__, #x)) |
Used instead of standard assert() macro for implementing Design by Contract. | |
#define | DEBUG_ASSERT(x) CHECK_ASSERT(x) |
The same as CHECK_ASSERT() macro. | |
Functions | |
void | Assertion::setHandler (AssertHandler *handler) |
Set AssertHandler. | |
#define CHECK_ASSERT | ( | x | ) | ((x) ? (void)0 : Assertion::Failure::assertFail(__FILE__, __LINE__, #x)) |
Used instead of standard assert() macro for implementing Design by Contract.
If an assertion fails, you must handle to do shutdown your application safely. In the assertion failure function, the Assertion::AssertHandler that is set by Assertion::setHandler() is called. If Assertion::AssertHandler is not set, the exception Assertion::Failure is thrown.
#define CPPELIB_ASSERTION_FAILURE_BUFSIZE (512) |
Buffer size of Assertion::Failure object.
This buffer is used as assertion failure message when an assertion fails. That time, Assertion::Failure object is allocated on the stack. If the stack size of the thread is small, you can define this macro by preprocessor according as the stack size. If you define this buffer size smaller than the default value, assertion failure message might be cut off.
#define DEBUG_ASSERT | ( | x | ) | CHECK_ASSERT(x) |
The same as CHECK_ASSERT() macro.