$treeview $search $mathjax $extrastylesheet
avr-libc  2.0.0
$projectbrief
$projectbrief
$searchbox

AVR Libc Home Page

AVRs

AVR Libc Development Pages

Main Page

User Manual

Library Reference

FAQ

Example Projects

assert.h

Go to the documentation of this file.
00001 /* Copyright (c) 2005,2007 Joerg Wunsch
00002    All rights reserved.
00003 
00004    Portions of documentation Copyright (c) 1991, 1993
00005    The Regents of the University of California.
00006 
00007    All rights reserved.
00008 
00009    Redistribution and use in source and binary forms, with or without
00010    modification, are permitted provided that the following conditions are met:
00011 
00012    * Redistributions of source code must retain the above copyright
00013      notice, this list of conditions and the following disclaimer.
00014 
00015    * Redistributions in binary form must reproduce the above copyright
00016      notice, this list of conditions and the following disclaimer in
00017      the documentation and/or other materials provided with the
00018      distribution.
00019 
00020    * Neither the name of the copyright holders nor the names of
00021      contributors may be used to endorse or promote products derived
00022      from this software without specific prior written permission.
00023 
00024   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00025   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00026   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00027   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00028   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00029   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00030   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00031   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00032   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00033   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00034   POSSIBILITY OF SUCH DAMAGE.
00035 
00036   $Id$
00037 */
00038 
00039 /** \file */
00040 /** \defgroup avr_assert <assert.h>: Diagnostics
00041     \code #include <assert.h> \endcode
00042 
00043     This header file defines a debugging aid.
00044 
00045     As there is no standard error output stream available for many
00046     applications using this library, the generation of a printable
00047     error message is not enabled by default.  These messages will
00048     only be generated if the application defines the macro
00049 
00050     \code __ASSERT_USE_STDERR \endcode
00051 
00052     before including the \c <assert.h> header file.  By default,
00053     only abort() will be called to halt the application.
00054 */
00055 
00056 /*@{*/
00057 
00058 /*
00059  * The ability to include this file (with or without NDEBUG) is a
00060  * feature.
00061  */
00062 
00063 #undef assert
00064 
00065 #include <stdlib.h>
00066 
00067 #if defined(__DOXYGEN__)
00068 /**
00069  * \def assert
00070  * \param expression Expression to test for.
00071  *
00072  * The assert() macro tests the given expression and if it is false,
00073  * the calling process is terminated.  A diagnostic message is written
00074  * to stderr and the function abort() is called, effectively
00075  * terminating the program.
00076  *
00077  * If expression is true, the assert() macro does nothing.
00078  *
00079  * The assert() macro may be removed at compile time by defining
00080  * NDEBUG as a macro (e.g., by using the compiler option -DNDEBUG).
00081  */
00082 #  define assert(expression)
00083 
00084 #else /* !DOXYGEN */
00085 
00086 #  if defined(NDEBUG)
00087 #    define assert(e)   ((void)0)
00088 #  else /* !NDEBUG */
00089 #    if defined(__ASSERT_USE_STDERR)
00090 #      define assert(e) ((e) ? (void)0 : \
00091                          __assert(__func__, __FILE__, __LINE__, #e))
00092 #    else /* !__ASSERT_USE_STDERR */
00093 #      define assert(e) ((e) ? (void)0 : abort())
00094 #    endif /* __ASSERT_USE_STDERR */
00095 #  endif /* NDEBUG */
00096 #endif /* DOXYGEN */
00097 
00098 #if (defined __STDC_VERSION__ && __STDC_VERSION__ >= 201112L) || \
00099     ((_GNUC_ > 4 || (_GNUC_ == 4 && _GNUC_MINOR_ >= 6)) && !defined __cplusplus)
00100 #  undef static_assert
00101 #  define static_assert _Static_assert
00102 #endif
00103 
00104 #ifdef __cplusplus
00105 extern "C" {
00106 #endif
00107 
00108 #if !defined(__DOXYGEN__)
00109 
00110 extern void __assert(const char *__func, const char *__file,
00111              int __lineno, const char *__sexp);
00112 
00113 #endif /* not __DOXYGEN__ */
00114 
00115 #ifdef __cplusplus
00116 }
00117 #endif
00118 
00119 /*@}*/
00120 /* EOF */
 All Data Structures Files Functions Variables Typedefs Enumerations Defines