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