1assert(3C)               Standard C Library Functions               assert(3C)
2
3
4

NAME

6       assert - verify program assertion
7

SYNOPSIS

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

DESCRIPTION

15       The  assert()  macro  inserts  diagnostics into applications. When exe‐
16       cuted, if expression is FALSE (zero), assert() prints the error message
17
18         Assertion failed: expression, file xyz, line nnn
19
20
21
22       on the standard error output and aborts. In the error message,  xyz  is
23       the  name  of  the  source  file  and nnn the source line number of the
24       assert() statement. These are respectively the values of the preproces‐
25       sor macros __FILE__ and __LINE__.
26
27
28       Since  assert()  is implemented as a macro, the expression may not con‐
29       tain any string literals.
30
31
32       Compiling with the preprocessor option -DNDEBUG or with the  preproces‐
33       sor  control  statement #define NDEBUG ahead of the #include <assert.h>
34       statement, will stop assertions from being compiled into the program.
35
36
37       Messages printed from this function are in the native  language  speci‐
38       fied by the LC_MESSAGES locale category. See setlocale(3C).
39

ATTRIBUTES

41       See attributes(5) for descriptions of the following attributes:
42
43
44
45
46       ┌─────────────────────────────┬─────────────────────────────┐
47       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
48       ├─────────────────────────────┼─────────────────────────────┤
49       │Interface Stability          │Committed                    │
50       ├─────────────────────────────┼─────────────────────────────┤
51       │MT-Level                     │Safe                         │
52       ├─────────────────────────────┼─────────────────────────────┤
53       │Standard                     │See standards(5).            │
54       └─────────────────────────────┴─────────────────────────────┘
55

SEE ALSO

57       abort(3C), gettext(3C), setlocale(3C), attributes(5), standards(5)
58
59
60
61SunOS 5.11                        30 Mar 2005                       assert(3C)
Impressum