]> pd.if.org Git - pdclib/blob - includes/assert.h
ebf4d8c15b4eac6224415223754ba50459264ebd
[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 // 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
21
22 // ----------------------------------------------------------------------------
23 // DEFINES
24
25 // TODO: Check the macro for if-compatibility.
26
27 #undef assert
28 #if defined NDEBUG
29 #define assert( x ) ( (void) 0 )
30 #else
31 #define assert( x ) ( x ) ? ( (void) 0 ) \
32                           :  __assert( #x, __FILE__, __func__, __LINE__ )
33 #endif
34
35 #endif // __ASSERT_H