]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/assert.3
getent.1, intro.1, time.1, _exit.2, _syscall.2, accept.2, access.2, acct.2, adjtimex...
[thirdparty/man-pages.git] / man3 / assert.3
CommitLineData
bf5a7247 1.\" Copyright (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de)
fea681da
MK
2.\"
3.\" Permission is granted to make and distribute verbatim copies of this
4.\" manual provided the copyright notice and this permission notice are
5.\" preserved on all copies.
6.\"
7.\" Permission is granted to copy and distribute modified versions of this
8.\" manual under the conditions for verbatim copying, provided that the
9.\" entire resulting derived work is distributed under the terms of a
10.\" permission notice identical to this one.
c13182ef 11.\"
fea681da
MK
12.\" Since the Linux kernel and libraries are constantly changing, this
13.\" manual page may be incorrect or out-of-date. The author(s) assume no
14.\" responsibility for errors or omissions, or for damages resulting from
15.\" the use of the information contained herein. The author(s) may not
16.\" have taken the same level of care in the production of this manual,
17.\" which is licensed free of charge, as they might when working
18.\" professionally.
c13182ef 19.\"
fea681da
MK
20.\" Formatted or processed versions of this manual, if unaccompanied by
21.\" the source, must acknowledge the copyright and authors of this work.
22.\" License.
23.\" Modified Sat Jul 24 21:42:42 1993 by Rik Faith <faith@cs.unc.edu>
24.\" Modified Tue Oct 22 23:44:11 1996 by Eric S. Raymond <esr@thyrsus.com>
69962544 25.TH ASSERT 3 2002-08-25 "GNU" "Linux Programmer's Manual"
fea681da
MK
26.SH NAME
27assert \- abort the program if assertion is false
28.SH SYNOPSIS
29.nf
30.B #include <assert.h>
31.sp
32.BI "void assert(scalar " expression );
33.fi
34.SH DESCRIPTION
35If the macro
36.B NDEBUG
37was defined at the moment
bd12ab88 38.I <assert.h>
fea681da 39was last included, the macro
63aa9df0 40.BR assert ()
fea681da
MK
41generates no code, and hence does nothing at all.
42Otherwise, the macro
63aa9df0 43.BR assert ()
4c39c55c 44prints an error message to standard error and terminates the program
fea681da 45by calling
fb186734 46.BR abort (3)
fea681da
MK
47if
48.I expression
49is false (i.e., compares equal to zero).
50.LP
51The purpose of this macro is to help the programmer find bugs in
c13182ef
MK
52his program.
53The message "assertion failed in file foo.c, function
fea681da 54do_bar(), line 1287" is of no help at all to a user.
47297adb 55.SH RETURN VALUE
fea681da 56No value is returned.
47297adb 57.SH CONFORMING TO
68e1685c
MK
58POSIX.1-2001, C89, C99.
59In C89,
fea681da
MK
60.I expression
61is required to be of type
9ff08aad 62.I int
68e1685c 63and undefined behavior results if it is not, but in C99
fea681da
MK
64it may have any scalar type.
65.\" See Defect Report 107 for more details.
66.SH BUGS
63aa9df0 67.BR assert ()
fea681da 68is implemented as a macro; if the expression tested has side-effects,
d9bfdb9c 69program behavior will be different depending on whether
fea681da 70.B NDEBUG
c13182ef
MK
71is defined.
72This may create Heisenbugs which go away when debugging
fea681da 73is turned on.
47297adb 74.SH SEE ALSO
fea681da
MK
75.BR abort (3),
76.BR assert_perror (3),
77.BR exit (3)