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(3) 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 behavior will be different depending on whether NDEBUG
35       is defined.  This may create Heisenbugs which go away when debugging is
36       turned on.
37

SEE ALSO

39       abort(3), assert_perror(3), exit(3)
40

COLOPHON

42       This page is part of release 3.53 of the Linux  man-pages  project.   A
43       description  of  the project, and information about reporting bugs, can
44       be found at http://www.kernel.org/doc/man-pages/.
45
46
47
48GNU                               2002-08-25                         ASSERT(3)
Impressum