]> pd.if.org Git - pdclib/blob - includes/assert.h
Various updates. Made assert() no longer rely on standard version. Removed _PDCLIB_C_...
[pdclib] / includes / assert.h
1 /* Diagnostics <assert.h>
2
3    This file is part of the Public Domain C Library (PDCLib).
4    Permission is granted to use, modify, and / or redistribute at will.
5 */
6
7 #include <_PDCLIB_aux.h>
8
9 #ifndef _PDCLIB_ASSERT_H
10 #define _PDCLIB_ASSERT_H _PDCLIB_ASSERT_H
11 void _PDCLIB_assert99( char const * const, char const * const, char const * const );
12 void _PDCLIB_assert89( char const * const );
13 #endif
14
15 /* If NDEBUG is set, assert() is a null operation. */
16 #undef assert
17
18 #ifdef NDEBUG
19 #define assert( ignore ) ( (void) 0 )
20 #else
21 #if __STDC_VERSION__ >= 199901L
22 #define assert( expression ) ( ( expression ) ? (void) 0 \
23         : _PDCLIB_assert99( "Assertion failed: " #expression \
24                             ", function ", __func__, \
25                             ", file " __FILE__ \
26                             ", line " _PDCLIB_symbol2string( __LINE__ ) \
27                             "." _PDCLIB_endl ) )
28 #else
29 #define assert( expression ) ( ( expression ) ? (void) 0 \
30         : _PDCLIB_assert89( "Assertion failed: " #expression \
31                             ", file " __FILE__ \
32                             ", line " _PDCLIB_symbol2string( __LINE__ ) \
33                             "." _PDCLIB_endl ) )
34 #endif
35 #endif