'\"macro stdmacro
.if n .pH g3x.assert @(#)assert	40.8 of 10/10/89
.\" Copyright 1989 AT&T
.nr X
.if \nX=0 .ds x} assert 3X "Specialized Libraries" "\&"
.if \nX=1 .ds x} assert 3X "Specialized Libraries"
.if \nX=2 .ds x} assert 3X "" "\&"
.if \nX=3 .ds x} assert "" "" "\&"
.TH \*(x}
.SH NAME
\f4assert\f1 \- verify program assertion
.SH SYNOPSIS
\f4#include <assert.h>\f1
.PP
\f4void assert (int expression);\f1
.SH DESCRIPTION
This macro is useful for putting diagnostics into programs.
When it is executed, if
.I expression\^
is false (zero),
\f4assert\fP
prints
.PP
.RS
.ft 5
Assertion failed: \f2expression\fP, file \f2xyz\fP, line \f2nnn\fP
.ft 1
.RE
.PP
on the standard error output and aborts.
In the error message,
.I xyz\^
is the name of the source file and
.I nnn\^
the source line number
of the
\f4assert\fP
statement.
The latter are respectively the values of the preprocessor macros
\f4__FILE__\fP and \f4__LINE__\fP.
.PP
Compiling with the preprocessor option
\f4\-DNDEBUG\f1
[see
\f4cc\fP(1)],
or with the preprocessor control statement
\f4#define NDEBUG\fP
ahead of the
\f4#include <assert.h>\fP statement,
will stop assertions from
being compiled into the program.
.SH "SEE ALSO"
\f4cc\fP(1),
\f4abort\fP(3C).
.SH "NOTES"
Since
\f4assert\fP
is implemented as a macro, the
.I expression\^
may not contain any string literals.
.\"	@(#)assert.3x	6.2 of 10/20/83
.Ee
