qassert.h File Reference

Customizable assertions. More...

Go to the source code of this file.

Defines

#define Q_DEFINE_THIS_FILE   static char const Q_ROM Q_ROM_VAR l_this_file[] = __FILE__;
#define Q_DEFINE_THIS_MODULE(name_)   static char const Q_ROM Q_ROM_VAR l_this_file[] = #name_;
#define Q_ASSERT(test_)
#define Q_ALLEGE(test_)   Q_ASSERT(test_)
#define Q_ERROR()   (Q_onAssert(l_this_file, __LINE__))
#define Q_REQUIRE(test_)   Q_ASSERT(test_)
#define Q_ENSURE(test_)   Q_ASSERT(test_)
#define Q_INVARIANT(test_)   Q_ASSERT(test_)
#define Q_ASSERT_COMPILE(test_)   extern char Q_assert_compile[(test_)]

Functions

void Q_onAssert (char const Q_ROM *const Q_ROM_VAR file, int line)


Detailed Description

Customizable assertions.

Defines customizable and memory-efficient assertions applicable to embedded systems. This header file can be used in C, C++, and mixed C/C++ programs.

Note:
The preprocessor switch Q_NASSERT disables checking assertions. In particular macros Q_ASSERT, Q_REQUIRE, Q_ENSURE, Q_INVARIANT, and Q_ERROR do NOT evaluate the test condition passed as the argument to these macros. One notable exception is the macro Q_ALLEGE, that still evaluates the test condition, but does not report assertion failures when the switch Q_NASSERT is defined.

Definition in file qassert.h.


Define Documentation

#define Q_ALLEGE ( test_   )     Q_ASSERT(test_)

General purpose assertion that ALWAYS evaluates the test_ argument and calls the Q_onAssert() callback if the test_ evaluates to FALSE.

Note:
the test_ argument IS always evaluated even when assertions are disabled with the Q_NASSERT macro. When the Q_NASSERT macro is defined, the Q_onAssert() callback is NOT called, even if the test_ evaluates to FALSE.

Definition at line 108 of file qassert.h.

Referenced by QHsm_init().

#define Q_ASSERT ( test_   ) 

Value:

if (test_) { \
        } \
        else (Q_onAssert(l_this_file, __LINE__))
General purpose assertion that makes sure the test_ argument is TRUE. Calls the Q_onAssert() callback if the test_ evaluates to FALSE.
Note:
the test_ is NOT evaluated if assertions are disabled with the Q_NASSERT switch.

Definition at line 95 of file qassert.h.

Referenced by QActive_post(), QActive_postISR(), QF_run(), QHsm_dispatch(), and QHsm_init().

#define Q_ASSERT_COMPILE ( test_   )     extern char Q_assert_compile[(test_)]

Compile-time assertion exploits the fact that in C/C++ a dimension of an array must be non-zero. The following declaration causes a compilation error if the compile-time expression (test_) is not TRUE. The assertion has no runtime side effects.

Definition at line 142 of file qassert.h.

#define Q_DEFINE_THIS_FILE   static char const Q_ROM Q_ROM_VAR l_this_file[] = __FILE__;

Place this macro at the top of each C/C++ module to define the file name string using __FILE__ (NOTE: __FILE__ might contain lengthy path name). This file name will be used in reporting assertions in this file.

Definition at line 79 of file qassert.h.

#define Q_DEFINE_THIS_MODULE ( name_   )     static char const Q_ROM Q_ROM_VAR l_this_file[] = #name_;

Place this macro at the top of each C/C++ module to define the module name as the argument name_. This file name will be used in reporting assertions in this file.

Definition at line 86 of file qassert.h.

#define Q_ENSURE ( test_   )     Q_ASSERT(test_)

Assertion that checks for a postcondition. This macro is equivalent to Q_ASSERT, except the name provides a better documentation of the intention of this assertion.

Definition at line 129 of file qassert.h.

 
#define Q_ERROR (  )     (Q_onAssert(l_this_file, __LINE__))

Assertion that always calls the Q_onAssert() callback if ever executed.

Note:
can be disabled with the Q_NASSERT switch.

Definition at line 114 of file qassert.h.

#define Q_INVARIANT ( test_   )     Q_ASSERT(test_)

Assertion that checks for an invariant. This macro is equivalent to Q_ASSERT, except the name provides a better documentation of the intention of this assertion.

Definition at line 135 of file qassert.h.

#define Q_REQUIRE ( test_   )     Q_ASSERT(test_)

Assertion that checks for a precondition. This macro is equivalent to Q_ASSERT, except the name provides a better documentation of the intention of this assertion.

Definition at line 123 of file qassert.h.


Function Documentation

void Q_onAssert ( char const Q_ROM *const Q_ROM_VAR  file,
int  line 
)

callback invoked in case the condition passed to Q_ASSERT, Q_REQUIRE, Q_ENSURE, Q_ERROR, or Q_ALLEGE evaluates to FALSE.

Parameters:
file file name where the assertion failed
line line number at which the assertion failed


Generated on Sat Dec 27 22:01:46 2008 for QP-nano by  doxygen 1.5.4