]> pd.if.org Git - pdclib/blob - includes/assert.h
Re-import from Subversion.
[pdclib] / includes / assert.h
1 /* ----------------------------------------------------------------------------
2  * $Id$
3  * ----------------------------------------------------------------------------
4  * Public Domain C Library - http://pdclib.sourceforge.net
5  * This code is Public Domain. Use, modify, and redistribute at will.
6  * ----------------------------------------------------------------------------
7  * Diagnostics
8  * --------------------------------------------------------------------------*/
9
10 #ifndef _ASSERT_H
11 #define _ASSERT_H _ASSERT_H
12
13 /* ----------------------------------------------------------------------------
14  * AUXILIARY
15  * --------------------------------------------------------------------------*/
16
17 /* Helper function doing the print to stderr and call to abort(). */
18 void __assert( char const * const expression, /* the tested expression       */
19                char const * const file,       /* name of source file         */
20                char const * const function,   /* name of function            */
21                int const line );              /* number of source file line  */
22
23 #endif /* _ASSERT_H - note that the header guard ends here on purpose. The
24                       assert macro is redefined upon each inclusion, in
25                       dependence of NDEBUG.                                  */
26
27 /* ----------------------------------------------------------------------------
28  * DEFINES
29  * --------------------------------------------------------------------------*/
30
31 #undef assert
32 #if defined NDEBUG
33 #define assert( x ) ( (void) 0 )
34 #else
35 #define assert( x ) ( x ) ? ( (void) 0 ) \
36                           :  __assert( #x, __FILE__, __func__, __LINE__ )
37 #endif