Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/dinkum_en/c99/assert.html on line 1
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/dinkum_en/c99/assert.html on line 1
Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/dinkum_en/c99/assert.html on line 4
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/dinkum_en/c99/assert.html on line 4
Include the standard header <assert.h>
to define the macro
assert
,
which is useful for diagnosing logic errors in
the program. You can eliminate the testing code produced by the macro
assert
without removing the macro references from the program
by defining the macro
NDEBUG
in the program before you include
<assert.h>
. Each time the program includes this header,
it redetermines the definition of the macro assert
.
#undef assert
#if defined NDEBUG
#define assert(test) (void)0
#else
#define assert(test) <void expression>
#endif
#undef assert
#if defined NDEBUG
#define assert(test) (void)0
#else
#define assert(test) <void expression>
#endif
If the int expression test
equals zero,
the macro writes to
stderr
a diagnostic message that includes:
- the text of
test
- the source filename (the predefined macro
__FILE__
)
- the source line number (the predefined macro
__LINE__
)
- the function name (the predefined object
__func__
,
added with C99)
It then calls
abort
.
You can write the macro assert
in the program in any
side-effects context.
See also the
Table of Contents and the
Index.
Copyright © 1989-2002
by P.J. Plauger and Jim Brodie. All rights reserved.
Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/dinkum_en/c99/assert.html on line 90
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/dinkum_en/c99/assert.html on line 90