Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Watcom C Library Reference - <u>synopsis:</u> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Synopsis:
    #include <assert.h>
    void assert( int expression );

Description:
    The assert macro prints a diagnostic message upon the  stderr stream and
    terminates the program 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.  Filename and
    linenumber are the values of the preprocessing macros  __FILE__ and
     __LINE__ respectively.  No action is taken if expression is true
    (non-zero).

    The assert macro is typically used during program development to
    identify program logic errors.  The given expression should be chosen so
    that it is true when the program is functioning as intended.  After the
    program has been debugged, the special "no debug" identifier  NDEBUG can
    be used to remove assert calls from the program when it is re-compiled.
    If  NDEBUG is defined (with any value) with a -d command line option or
    with a #define directive, the C preprocessor ignores all assert calls in
    the program source.

Returns:
    The assert macro does not return a value.

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

    void process_string( char *string )
      {
        /* use assert to check argument */
        assert( string != NULL );
        assert( *string != '\0' );
        /* rest of code follows here */
      }

    void main()
      {
        process_string( "hello" );
        process_string( "" );
      }

Classification:
    ANSI

Systems:
    MACRO

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