sys_write(fd, s, 1);
}
+int
_BadAssertion(file, lineno, assertion)
char *file, *assertion;
int lineno;
sys_write(STDERR, assertion, strlen(assertion));
sys_write(STDERR, "\" failed\n", 9);
sys_stop(S_ABORT);
+ return 0;
}
.IR sys_stop (S_ABORT)
with a diagnostic comment on standard error.
.PP
-The assertions are enabled by defining the preprocessor constant DEBUG.
+The assertions are disabled by defining the preprocessor constant NDEBUG.
.SH DIAGNOSTICS
.IR fn ,
line
/* $Header$ */
/* A S S E R T I O N M A C R O D E F I N I T I O N */
-#ifdef DEBUG
-#ifdef __STDC__
-#define assert(exp) ((exp) || _BadAssertion(__FILE__, __LINE__, #exp))
+/* This 'assert' definition can be used in a ,-expression. */
+
+#ifndef NDEBUG
+#if __STDC__
+int _BadAssertion(char *, int, char *);
+#define assert(exp) ((void)((exp) || _BadAssertion(__FILE__, __LINE__, #exp)))
#else
/* Note: this macro uses parameter substitution inside strings */
#define assert(exp) ((exp) || _BadAssertion(__FILE__, __LINE__, "exp"))
#endif
#else
-#define assert(exp) (1)
-#endif /* DEBUG */
+#if __STDC__
+#define assert(exp) ((void)0)
+#else
+#define assert(exp) (0)
+#endif
+#endif /* NDEBUG */