3 <<assert>>---macro for debugging diagnostics
10 void assert(int <[expression]>);
13 Use this macro to embed debuggging diagnostic statements in
14 your programs. The argument <[expression]> should be an
15 expression which evaluates to true (nonzero) when your program
16 is working as you intended.
18 When <[expression]> evaluates to false (zero), <<assert>>
19 calls <<abort>>, after first printing a message showing what
22 . Assertion failed: <[expression]>, file <[filename]>, line <[lineno]>, function: <[func]>
24 If the name of the current function is not known (for example,
25 when using a C89 compiler that does not understand __func__),
26 the function location is omitted.
28 The macro is defined to permit you to turn off all uses of
29 <<assert>> at compile time by defining <<NDEBUG>> as a
30 preprocessor variable. If you do this, the <<assert>> macro
36 <<assert>> does not return a value.
39 The <<assert>> macro is required by ANSI, as is the behavior
40 when <<NDEBUG>> is defined.
42 Supporting OS subroutines required (only if enabled): <<close>>, <<fstat>>,
43 <<getpid>>, <<isatty>>, <<kill>>, <<lseek>>, <<read>>, <<sbrk>>, <<write>>.
50 #ifndef HAVE_ASSERT_FUNC
51 /* func can be NULL, in which case no function information is given. */
53 __assert_func (const char *file
,
56 const char *failedexpr
)
59 "assertion \"%s\" failed: file \"%s\", line %d%s%s\n",
60 failedexpr
, file
, line
,
61 func
? ", function: " : "", func
? func
: "");
65 #endif /* HAVE_ASSERT_FUNC */
68 __assert (const char *file
,
70 const char *failedexpr
)
72 __assert_func (file
, line
, NULL
, failedexpr
);