]> pd.if.org Git - pdclib/blob - includes/assert.h
Merged branch stdio_rewrite back into trunk.
[pdclib] / includes / assert.h
1 /* $Id$ */
2
3 /* 7.2 Diagnostics <assert.h>
4
5    This file is part of the Public Domain C Library (PDCLib).
6    Permission is granted to use, modify, and / or redistribute at will.
7 */
8
9 #ifndef _PDCLIB_AUX_H
10 #define _PDCLIB_AUX_H _PDCLIB_AUX_H
11 #include <_PDCLIB_aux.h>
12 #endif
13
14 #ifndef _PDCLIB_CONFIG_H
15 #define _PDCLIB_CONFIG_H _PDCLIB_CONFIG_H
16 #include <_PDCLIB_config.h>
17 #endif
18
19 #ifndef _PDCLIB_ASSERT_H
20 #define _PDCLIB_ASSERT_H _PDCLIB_ASSERT_H
21 #if _PDCLIB_C_VERSION == 99
22 void _PDCLIB_assert( char const * const, char const * const, char const * const );
23 #else
24 void _PDCLIB_assert( char const * const );
25 #endif
26 #endif
27
28 /* If NDEBUG is set, assert() is a null operation. */
29 #undef assert
30
31 #ifdef NDEBUG
32 #define assert( ignore ) ( (void) 0 )
33 #else
34 #if _PDCLIB_C_VERSION == 99
35 #define assert( expression ) ( ( expression ) ? (void) 0 \
36         : _PDCLIB_assert( "Assertion failed: " #expression \
37                           ", function ", __func__, \
38                           ", file " __FILE__ \
39                           ", line " _PDCLIB_symbol2string( __LINE__ ) \
40                           "." _PDCLIB_endl ) )
41 #else
42 #define assert( expression ) ( ( expression ) ? (void) 0 \
43         : _PDCLIB_assert( "Assertion failed: " #expression \
44                           ", file " __FILE__ \
45                           ", line " _PDCLIB_symbol2string( __LINE__ ) \
46                           "." _PDCLIB_endl ) )
47 #endif
48 #endif
49