1.\" Copyright (c) 1991 Regents of the University of California. 2.\" All rights reserved. 3.\" 4.\" %sccs.include.redist.man% 5.\" 6.\" @(#)assert.3 6.3 (Berkeley) 04/19/91 7.\" 8.Dd 9.Dt ASSERT 3 10.Os 11.Sh NAME 12.Nm assert 13.Nd expression verification macro 14.Sh SYNOPSIS 15.Fd #include <assert.h> 16.Fn assert expression 17.Sh DESCRIPTION 18The 19.Fn assert 20macro tests the given 21.Ar expression 22and if it is false, 23the calling process is terminated. 24A 25diagnostic message is written to the 26.Em stderr 27and the function 28.Xr _exit 2 29is called effectively terminating the program. 30.Pp 31If 32.Ar expression 33is true, 34the 35.Fn assert 36macro does nothing. 37.Pp 38The 39.Fn assert 40macro 41may be removed at compile time with 42the 43.Fl NDEBUG 44option, see 45.Xr cc 1 . 46.Sh DIAGNOSTICS 47The following diagnostic message is written to 48.Em stderr 49if 50.Ar expression 51is false: 52.Bd -literal -offset indent 53"assertion \e"%s\e" failed: file \e"%s\e", line %d\n", \e 54 "expression", __FILE__, __LINE__); 55.Ed 56.Sh HISTORY 57The 58.Fn assert 59function is 60.Ud . 61