|
|
1.1 root 1:
2:
3: assert() Macro assert()
4:
5:
6:
7:
8: Check assertion at run time
9:
10: #include <assert.h>
11: vvooiidd aasssseerrtt(_e_x_p_r_e_s_s_i_o_n) iinntt _e_x_p_r_e_s_s_i_o_n;
12:
13: assert checks the value of expression. If expression is false
14: (zero), assert sends a message into the standard-error stream and
15: calls exit. It is useful for verifying that a necessary con-
16: dition is true.
17:
18: The error message includes the text of the assertion that failed,
19: the name of the source file, and the line within the source file
20: that holds the expression in question. These last two elements
21: consist, respectively, of the values of the preprocessor macros
22: _ _FILE_ _ and _ _LINE_ _.
23:
24: assert calls exit, which never returns.
25:
26: To turn off assert, define the macro NDEBUG prior to including
27: the header assert.h. This forces assert to be redefined as
28:
29:
30: #define assert(ignore)
31:
32:
33: ***** See Also *****
34:
35: exit(), assert.h, C preprocessor
36:
37: ***** Notes *****
38:
39: The Standard requires that assert be implemented as a macro, not
40: a library function. If a program suppresses the macro definition
41: in favor of a function call, its behavior is undefined.
42:
43: Turning off assert with the macro NDEBUG will affect the behavior
44: of a program if the expression being evaluated normally generates
45: side effects.
46:
47: assert is useful for debugging, and for testing boundary con-
48: ditions for which more graceful error recovery has not yet been
49: implemented.
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64: COHERENT Lexicon Page 1
65:
66:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.