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