Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Turbo C - <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>

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

    assert() tests 'expression'. If 'expression' fails, assert() prints a
    diagnostic message and aborts the calling process. 'expression'
    should be chosen so it is true if the program is operating correctly.
    No action is taken if 'expression' is true (nonzero).

    The diagnostic message has the form:

        Assertion failed: 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:    There is no return value.

      Notes:    assert() is a macro.

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

  -------------------------------- 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 */
           }

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