1ASSERT(P) POSIX Programmer's Manual ASSERT(P)
2
3
4
6 assert - insert program diagnostics
7
9 #include <assert.h>
10
11 void assert(scalar expression);
12
13
15 The assert() macro shall insert diagnostics into programs; it shall
16 expand to a void expression. When it is executed, if expression (which
17 shall have a scalar type) is false (that is, compares equal to 0),
18 assert() shall write information about the particular call that failed
19 on stderr and shall call abort().
20
21 The information written about the call that failed shall include the
22 text of the argument, the name of the source file, the source file line
23 number, and the name of the enclosing function; the latter are, respec‐
24 tively, the values of the preprocessing macros __FILE__ and __LINE__
25 and of the identifier __func__.
26
27 Forcing a definition of the name NDEBUG, either from the compiler com‐
28 mand line or with the preprocessor control statement #define NDEBUG
29 ahead of the #include <assert.h> statement, shall stop assertions from
30 being compiled into the program.
31
33 The assert() macro shall not return a value.
34
36 No errors are defined.
37
38 The following sections are informative.
39
41 None.
42
44 None.
45
47 None.
48
50 None.
51
53 abort() , stderr, the Base Definitions volume of IEEE Std 1003.1-2001,
54 <assert.h>
55
57 Portions of this text are reprinted and reproduced in electronic form
58 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
59 -- Portable Operating System Interface (POSIX), The Open Group Base
60 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
61 Electrical and Electronics Engineers, Inc and The Open Group. In the
62 event of any discrepancy between this version and the original IEEE and
63 The Open Group Standard, the original IEEE and The Open Group Standard
64 is the referee document. The original Standard can be obtained online
65 at http://www.opengroup.org/unix/online.html .
66
67
68
69IEEE/The Open Group 2003 ASSERT(P)