The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/include/assert.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /* The <assert.h> header contains a macro called "assert" that allows 
    2  * programmers to put assertions in the code.  These assertions can be verified
    3  * at run time.  If an assertion fails, an error message is printed and the
    4  * program aborts.
    5  * Assertion checking can be disabled by adding the statement
    6  *
    7  *      #define NDEBUG
    8  *
    9  * to the program before the 
   10  *
   11  *      #include <assert.h>
   12  *
   13  * statement.
   14  */
   15 
   16 #undef assert
   17 
   18 #ifndef _ANSI_H
   19 #include <ansi.h>
   20 #endif
   21 
   22 #ifdef NDEBUG
   23 /* Debugging disabled -- do not evaluate assertions. */
   24 #define assert(expr)  ((void) 0)
   25 #else
   26 /* Debugging enabled -- verify assertions at run time. */
   27 #ifdef _ANSI
   28 #define __str(x)        # x
   29 #define __xstr(x)       __str(x)
   30 
   31 _PROTOTYPE( void __bad_assertion, (const char *_mess) );
   32 #define assert(expr)    ((expr)? (void)0 : \
   33                                 __bad_assertion("Assertion \"" #expr \
   34                                     "\" failed, file " __xstr(__FILE__) \
   35                                     ", line " __xstr(__LINE__) "\n"))
   36 #else
   37 #define assert(expr) ((void) ((expr) ? 0 : __assert( __FILE__,  __LINE__)))
   38 #endif /* _ANSI */
   39 #endif

Cache object: 53437bb9ca80788be388e3aaca6968ee


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.