.\" Copyright (c) 1991 Regents of the University of California. .\" All rights reserved. .\" .\" %sccs.include.redist.man% .\" .\" @(#)assert.3 6.3 (Berkeley) 04/19/91 .\" .Dd .Dt ASSERT 3 .Os .Sh NAME .Nm assert .Nd expression verification macro .Sh SYNOPSIS .Fd #include .Fn assert expression .Sh DESCRIPTION The .Fn assert macro tests the given .Ar expression and if it is false, the calling process is terminated. A diagnostic message is written to the .Em stderr and the function .Xr _exit 2 is called effectively terminating the program. .Pp If .Ar expression is true, the .Fn assert macro does nothing. .Pp The .Fn assert macro may be removed at compile time with the .Fl NDEBUG option, see .Xr cc 1 . .Sh DIAGNOSTICS The following diagnostic message is written to .Em stderr if .Ar expression is false: .Bd -literal -offset indent "assertion \e"%s\e" failed: file \e"%s\e", line %d\n", \e "expression", __FILE__, __LINE__); .Ed .Sh HISTORY The .Fn assert function is .Ud .