2 .\" Copyright (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de)
4 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
6 .\" Modified Sat Jul 24 21:42:42 1993 by Rik Faith <faith@cs.unc.edu>
7 .\" Modified Tue Oct 22 23:44:11 1996 by Eric S. Raymond <esr@thyrsus.com>
8 .\" Modified Thu Jun 2 23:44:11 2016 by Nikos Mavrogiannopoulos <nmav@redhat.com>
9 .TH assert 3 (date) "Linux man-pages (unreleased)"
11 assert \- abort the program if assertion is false
14 .RI ( libc ", " \-lc )
17 .B #include <assert.h>
19 .BI "void assert(scalar " expression );
22 This macro can help programmers find bugs in their programs,
23 or handle exceptional cases
24 via a crash that will produce limited debugging output.
28 is false (i.e., compares equal to zero),
30 prints an error message to standard error
31 and terminates the program by calling
33 The error message includes the name of the file and function containing the
35 call, the source code line number of the call, and the text of the argument;
40 prog: some_file.c:16: some_func: Assertion \`val == 0\[aq] failed.
46 is defined at the moment
48 was last included, the macro
50 generates no code, and hence does nothing at all.
51 It is not recommended to define
55 to detect error conditions since the software
56 may behave non-deterministically.
60 For an explanation of the terms used in this section, see
66 Interface Attribute Value
71 T} Thread safety MT-Safe
76 C89, C99, POSIX.1-2001.
80 is required to be of type
82 and undefined behavior results if it is not, but in C99
83 it may have any scalar type.
84 .\" See Defect Report 107 for more details.
87 is implemented as a macro; if the expression tested has side-effects,
88 program behavior will be different depending on whether
91 This may create Heisenbugs which go away when debugging
95 .BR assert_perror (3),