X-Git-Url: https://pd.if.org/git/?p=pdclib;a=blobdiff_plain;f=includes%2Fassert.h;h=7bd6e41a6ded9145224628d42479ec32ec0e2274;hp=e03baaaae87c66a5adc653f084be53591eee99a1;hb=1d9d92ba957a0b8307c9a65c35867fde68e6533b;hpb=ad2651a3d8a2e2ae70a5ad882518ef346ab1bc7b diff --git a/includes/assert.h b/includes/assert.h index e03baaa..7bd6e41 100644 --- a/includes/assert.h +++ b/includes/assert.h @@ -1,35 +1,37 @@ -// ---------------------------------------------------------------------------- -// $Id$ -// ---------------------------------------------------------------------------- -// Public Domain C Library - http://pdclib.sourceforge.net -// This code is Public Domain. Use, modify, and redistribute at will. -// ---------------------------------------------------------------------------- -// Provides the debug macro assert(). -// ---------------------------------------------------------------------------- +/* ---------------------------------------------------------------------------- + * $Id$ + * ---------------------------------------------------------------------------- + * Public Domain C Library - http://pdclib.sourceforge.net + * This code is Public Domain. Use, modify, and redistribute at will. + * ---------------------------------------------------------------------------- + * Diagnostics + * --------------------------------------------------------------------------*/ -#ifndef __ASSERT_H -#define __ASSERT_H __ASSERT_H +#ifndef _ASSERT_H +#define _ASSERT_H _ASSERT_H -// ---------------------------------------------------------------------------- -// AUXILIARY +/* ---------------------------------------------------------------------------- + * AUXILIARY + * --------------------------------------------------------------------------*/ -// Helper function doing the print to stderr and call to abort(). -void __assert( char const * const expression, // the tested expression - char const * const file, // name of source file - char const * const function, // name of function - int const line ); // number of source file line +/* Helper function doing the print to stderr and call to abort(). */ +void __assert( char const * const expression, /* the tested expression */ + char const * const file, /* name of source file */ + char const * const function, /* name of function */ + int const line ); /* number of source file line */ -// ---------------------------------------------------------------------------- -// DEFINES +#endif /* _ASSERT_H - note that the header guard ends here on purpose. The + assert macro is redefined upon each inclusion, in + dependence of NDEBUG. */ -// TODO: Check the macro for if-compatibility. +/* ---------------------------------------------------------------------------- + * DEFINES + * --------------------------------------------------------------------------*/ #undef assert #if defined NDEBUG -#define assert( x ) (void) 0 +#define assert( x ) ( (void) 0 ) #else -#define assert( x ) ( x ) ? (void) 0 \ +#define assert( x ) ( x ) ? ( (void) 0 ) \ : __assert( #x, __FILE__, __func__, __LINE__ ) #endif - -#endif // __ASSERT_H