1 // ----------------------------------------------------------------------------
3 // ----------------------------------------------------------------------------
4 // Public Domain C Library - http://pdclib.sourceforge.net
5 // This code is Public Domain. Use, modify, and redistribute at will.
6 // ----------------------------------------------------------------------------
7 // Provides the debug macro assert().
8 // ----------------------------------------------------------------------------
11 #define __ASSERT_H __ASSERT_H
13 // ----------------------------------------------------------------------------
16 // Helper function doing the print to stderr and call to abort().
17 void __assert( char const * const expression, // the tested expression
18 char const * const file, // name of source file
19 char const * const function, // name of function
20 int const line ); // number of source file line
22 // ----------------------------------------------------------------------------
25 // TODO: <void expression> is given as (void) 0, which might give a "C style
26 // cast" warning under C++. Find a void expression that does not give warnings.
28 // TODO: Check the macro for if-compatibility.
32 #define assert( x ) <void expression>
34 #define assert( x ) ( x ) ? <void expression> \
35 : __assert( #x, __FILE__, __func__, __LINE__ )