Last change
on this file since 12 was 4, checked in by Mattia Monga, 14 years ago |
Importazione sorgenti libro
|
File size:
1.0 KB
|
Line | |
---|
1 | /* The <assert.h> header contains a macro called "assert" that allows
|
---|
2 | * programmers to put assertions in the code. These assertions can be verified
|
---|
3 | * at run time. If an assertion fails, an error message is printed and the
|
---|
4 | * program aborts.
|
---|
5 | * Assertion checking can be disabled by adding the statement
|
---|
6 | *
|
---|
7 | * #define NDEBUG
|
---|
8 | *
|
---|
9 | * to the program before the
|
---|
10 | *
|
---|
11 | * #include <assert.h>
|
---|
12 | *
|
---|
13 | * statement.
|
---|
14 | */
|
---|
15 |
|
---|
16 | #undef assert
|
---|
17 |
|
---|
18 | #ifndef _ANSI_H
|
---|
19 | #include <ansi.h>
|
---|
20 | #endif
|
---|
21 |
|
---|
22 | #ifdef NDEBUG
|
---|
23 | /* Debugging disabled -- do not evaluate assertions. */
|
---|
24 | #define assert(expr) ((void) 0)
|
---|
25 | #else
|
---|
26 | /* Debugging enabled -- verify assertions at run time. */
|
---|
27 | #ifdef _ANSI
|
---|
28 | #define __str(x) # x
|
---|
29 | #define __xstr(x) __str(x)
|
---|
30 |
|
---|
31 | _PROTOTYPE( void __bad_assertion, (const char *_mess) );
|
---|
32 | #define assert(expr) ((expr)? (void)0 : \
|
---|
33 | __bad_assertion("Assertion \"" #expr \
|
---|
34 | "\" failed, file " __xstr(__FILE__) \
|
---|
35 | ", line " __xstr(__LINE__) "\n"))
|
---|
36 | #else
|
---|
37 | #define assert(expr) ((void) ((expr) ? 0 : __assert( __FILE__, __LINE__)))
|
---|
38 | #endif /* _ANSI */
|
---|
39 | #endif
|
---|
Note:
See
TracBrowser
for help on using the repository browser.