Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Microsoft C 6.0 - <b>assert() diagnostic message generator</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 assert()                Diagnostic Message Generator

 #include   <assert.h>
 #include   <stdio.h>

 void       assert(expression);          Call removed if NDEBUG is defined.
 int        expression;

    assert() is a macro that tests 'expression'. If 'expression' fails,
    assert() prints a diagnostic message and aborts the calling process
    by calling abort(). If 'expression' is true, no action is taken;
    thus, 'expression' should be chosen so it is true if the program is
    operating correctly.

    The diagnostic message has the form:

        Assertion failed: 'expression', file 'filename', line
    'linenumber'

    where 'filename' is the source-file name and 'linenumber' is the line
    number where assert() appears.  assert() is used to identify program
    logic errors.

    Returns:    No return value.

                The C preprocessor will remove all assert() calls from a
                program if NDEBUG is defined with any value.  NDEBUG can
                be defined with the /D command-line option, or with a
                #define directive.

 Compatibility: MSC version 4.0 runtime library did not display
                'expression' in the diagnostic message.

   -------------------------------- Example ---------------------------------

    The following statement tests whether pshift is NULL and prints an
    appropriate message.

           #include <assert.h>
           #include <stdio.h>

           struct BASE {
                  char *name;
                  int number;
           } *pshift;

           main()
           {
               assert(pshift != NULL);
                 /* process item */
           }


See Also: abort() raise() signal()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson