1ASSERT(3)                  Linux Programmer's Manual                 ASSERT(3)
2
3
4

NAME

6       assert - abort the program if assertion is false
7

SYNOPSIS

9       #include <assert.h>
10
11       void assert(scalar expression);
12

DESCRIPTION

14       If  the  macro  NDEBUG  was  defined  at the moment <assert.h> was last
15       included, the macro assert() generates no code, and hence does  nothing
16       at all.  Otherwise, the macro assert() prints an error message to stan‐
17       dard error and terminates the program by calling abort() if  expression
18       is false (i.e., compares equal to zero).
19
20       The  purpose  of  this macro is to help the programmer find bugs in his
21       program.  The  message  "assertion  failed  in  file  foo.c,   function
22       do_bar(), line 1287" is of no help at all to a user.
23

RETURN VALUE

25       No value is returned.
26

CONFORMING TO

28       POSIX.1-2001,  C89,  C99.  In C89, expression is required to be of type
29       int and undefined behavior results if it is not, but in C99 it may have
30       any scalar type.
31

BUGS

33       assert()  is implemented as a macro; if the expression tested has side-
34       effects, program behaviour will be different depending on whether  NDE‐
35       BUG  is  defined.  This may create Heisenbugs which go away when debug‐
36       ging is turned on.
37

SEE ALSO

39       abort(3), assert_perror(3), exit(3)
40
41
42
43C99                               2002-08-25                         ASSERT(3)
Impressum