xref: /csrg-svn/share/man/man3/assert.3 (revision 62962)
1*62962Sbostic.\" Copyright (c) 1991, 1993
2*62962Sbostic.\"	The Regents of the University of California.  All rights reserved.
320287Smckusick.\"
448349Scael.\" %sccs.include.redist.man%
548349Scael.\"
6*62962Sbostic.\"     @(#)assert.3	8.1 (Berkeley) 06/09/93
748349Scael.\"
848349Scael.Dd
948349Scael.Dt ASSERT 3
1048349Scael.Os
1148349Scael.Sh NAME
1248349Scael.Nm assert
1348349Scael.Nd expression verification macro
1448349Scael.Sh SYNOPSIS
1548349Scael.Fd #include <assert.h>
1648349Scael.Fn assert expression
1748349Scael.Sh DESCRIPTION
1848349ScaelThe
1948349Scael.Fn assert
2048349Scaelmacro tests the given
2148349Scael.Ar expression
2248349Scaeland if it is false,
2348349Scaelthe calling process is terminated.
2448349ScaelA
2548349Scaeldiagnostic message is written to the
2648349Scael.Em stderr
2748349Scaeland the function
2848349Scael.Xr _exit 2
2948349Scaelis called effectively terminating the program.
3048349Scael.Pp
3148349ScaelIf
3248349Scael.Ar expression
3348349Scaelis true,
3448349Scaelthe
3548349Scael.Fn assert
3648349Scaelmacro does nothing.
3748349Scael.Pp
3848349ScaelThe
3948349Scael.Fn assert
4048349Scaelmacro
4148349Scaelmay be removed at compile time with
4248349Scaelthe
4348349Scael.Fl NDEBUG
4448349Scaeloption, see
4548349Scael.Xr cc 1 .
4648349Scael.Sh DIAGNOSTICS
4748349ScaelThe following diagnostic message is written to
4848349Scael.Em stderr
4948349Scaelif
5048349Scael.Ar expression
5148349Scaelis false:
5248349Scael.Bd -literal -offset indent
5348349Scael"assertion \e"%s\e" failed: file \e"%s\e", line %d\n", \e
5448349Scael		    "expression", __FILE__, __LINE__);
5548349Scael.Ed
5648349Scael.Sh HISTORY
5762961SbosticA
5862961Sbostic.Nm assert
5962961Sbosticmacro appeared in
6062961Sbostic.At v6 .
61