3 /* 7.2 Diagnostics <assert.h>
5 This file is part of the Public Domain C Library (PDCLib).
6 Permission is granted to use, modify, and / or redistribute at will.
9 #ifndef _PDCLIB_ASSERT_H
10 #define _PDCLIB_ASSERT_H _PDCLIB_ASSERT_H
11 #include <_PDCLIB_aux.h>
12 #include <_PDCLIB_config.h>
13 _PDCLIB_BEGIN_EXTERN_C
15 /* Functions _NOT_ tagged noreturn as this hampers debugging */
16 void _PDCLIB_assert99( char const * const, char const * const, char const * const );
17 void _PDCLIB_assert89( char const * const );
19 /* If NDEBUG is set, assert() is a null operation. */
23 #define assert( ignore ) do { \
24 if(!(expression)) { _PDCLIB_UNREACHABLE; } \
27 #elif _PDCLIB_C_MIN(99)
28 #define assert(expression) \
29 do { if(!(expression)) { \
30 _PDCLIB_assert99("Assertion failed: " _PDCLIB_symbol2string(expression)\
31 ", function ", __func__, \
33 ", line " _PDCLIB_symbol2string( __LINE__ ) \
35 _PDCLIB_UNREACHABLE; \
40 #define assert(expression) \
41 do { if(!(expression)) { \
42 _PDCLIB_assert89("Assertion failed: " _PDCLIB_symbol2string(expression)\
44 ", line " _PDCLIB_symbol2string( __LINE__ ) \
46 _PDCLIB_UNREACHABLE; \