]> pd.if.org Git - pdclib/blobdiff - includes/assert.h
Re-import from Subversion.
[pdclib] / includes / assert.h
index e4363f510f42ad4768d35ed28cd523452da61fa8..7bd6e41a6ded9145224628d42479ec32ec0e2274 100644 (file)
@@ -1,38 +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().
-// ----------------------------------------------------------------------------
-
-#ifndef __ASSERT_H
-#define __ASSERT_H __ASSERT_H
-
-// ----------------------------------------------------------------------------
-// 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
-
-// ----------------------------------------------------------------------------
-// DEFINES
-
-// TODO: <void expression> is given as (void) 0, which might give a "C style
-// cast" warning under C++. Find a void expression that does not give warnings.
-
-// TODO: Check the macro for if-compatibility.
+/* ----------------------------------------------------------------------------
+ * $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
+
+/* ----------------------------------------------------------------------------
+ * 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  */
+
+#endif /* _ASSERT_H - note that the header guard ends here on purpose. The
+                      assert macro is redefined upon each inclusion, in
+                      dependence of NDEBUG.                                  */
+
+/* ----------------------------------------------------------------------------
+ * DEFINES
+ * --------------------------------------------------------------------------*/
 
 #undef assert
 #if defined NDEBUG
-#define assert( x ) <void expression>
+#define assert( x ) ( (void) 0 )
 #else
-#define assert( x ) ( x ) ? <void expression> \
+#define assert( x ) ( x ) ? ( (void) 0 ) \
                           :  __assert( #x, __FILE__, __func__, __LINE__ )
 #endif
-
-#endif // __ASSERT_H