RKH
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
rkhassert.h File Reference

The assertions (RKH_ASSERT() macro) are used to check expressions that ought to be true as long as the program is running correctly. It is a convenient way to insert sanity checks. More...

#include "rkhcfg.h"

Go to the source code of this file.

Macros

#define RKH_MODULE_NAME(__fname)   static RKHROM char *const m_name = # __fname;
 This macro appears at the top of each C/C++ source file defining a name for that file. More...
 
#define RKH_THIS_MODULE   static RKHROM char *const m_name = __FILE__;
 This macro appears at the top of each C/C++ source file defining a name for that file, by means of FILE compiler directive.
 
#define RKH_ASSERT(exp)
 The RKH_ASSERT() macro is used to check expressions that ought to be true as long as the program is running correctly. More...
 
#define RKH_ALLEGE(exp)   RKH_ASSERT(exp)
 General purpose assertion that ALWAYS evaluates the exp argument and calls the RKH_ASSERT() macro if the exp evaluates to FALSE. More...
 
#define RKH_ERROR()   rkh_assert(m_name, __LINE__)
 Assertion that always calls the rkh_assert() callback if ever executed. More...
 
#define RKH_REQUIRE(exp)   RKH_ASSERT(exp)
 This macro checks the precondition. More...
 
#define RKH_ENSURE(exp)   RKH_ASSERT(exp)
 This macro checks the postcondition. More...
 
#define RKH_INVARIANT(exp)   RKH_ASSERT(exp)
 This macro is used to check a loop invariant. More...
 

Functions

void rkh_assert (const char *const file, int line)
 Callback invoked in case the condition passed to RKH_ASSERT(), RKH_REQUIRE(), RKH_ENSURE(), RKH_ERROR(), or RKH_ALLEGE() evaluates to FALSE. More...
 

Detailed Description

The assertions (RKH_ASSERT() macro) are used to check expressions that ought to be true as long as the program is running correctly. It is a convenient way to insert sanity checks.

A number of philosophies can be employed when deciding where to use an RKH_ASSERT() macro. Broadly speaking, the assertions only serve the purposes of catching bugs and helping documentation. Helping to document the code means that the statements inside the assertion tell the reader something he might not already know.

Definition in file rkhassert.h.