This header file refers to the QGARDEBUG macro name, which is not defined in the file. Assertions are therefore compiled into a program either when providing the (preprocessor) option -DQGARDEBUG in the command line invoking the compiler, or when defining QGARDEBUG as a macro name in the source code, before the inclusion of the present header file:
... #define QGARDEBUG // To be imperatively placed ahead of the #include below ... ... #include <qgarlib/assert.H> ...
Assertions are used in a similar way as standard macros assert() (see standard header file assert.h).
void qgarAssert(int EX)
If EX is false, print a diagnostic message on the standard error output and abort.
Execution of a user-defined function may be substituted for abortion: See macro setQgarAssertHandler.
void qgarAssertAndEval(EX, EX2)
Same as qgarAssert(EX), but EX2 is evaluated before abortion.
void qgarAssertAndCatch(EX, EX2)
Same as qgarAssertAndEval(EX, EX2), but does not abort: Execution proceeds sequentially when returning from the macro.
void setQgarAssertHandler(void (*HANDLER)(int))
Substitute the execution of a user-defined function for abortion in case of assertion failer. The function must conform to the following pattern:
#include <qgarlib/assert.H> ... void userHandler(int i) { signal(SIGABRT, SIG_IGN); ... ... // user-specific code ... signal(SIGABRT, userHandler); }
void resetQgarAssertHandler()
Restore abortion in case of assertion failer. See macro setQgarAssertHandler.
Definition in file assert.H.
Go to the source code of this file.
Namespaces | |
| namespace | qgar |
Functions | |
| void | qgar::__qgPrintAssert (const char *anExpr, const char *aFile, int aLine) |
| Print a diagnostic message about failure of an assertion. | |