Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
assert
◄Summary► ◄Example► ◄Up► ◄Contents► ◄Index► ◄Back►
────────────────────────────────────────────────────────────────────────────
The assert routine prints a diagnostic message and calls the abort
routine if <expression> is false (0). The diagnostic message has
the form
Assertion failed: expression, file filename, line linenumber
where <filename> is the name of the source file and <linenumber>
is the line number of the assertion that failed in the source
file. No action is taken if <expression> is true (nonzero).
The assert routine (implemented as a macro) is typically used to
identify program logic errors. The given expression should be
chosen so that it holds true only if the program is operating as
intended.
After a program has been debugged, the special "no debug"
identifier NDEBUG can be used to remove assert calls from the
program.
If NDEBUG is defined (by any value) with a /D command-line option
or with a #define directive, the C preprocessor removes all assert
calls from the program source. However, at warning level 4, you
will get the following warnings: 'Statement has no effect' and
'Unreferenced formal parameters.'
Return Value
None.
-♦-