assert.8h
Go to the
documentation of this file.
01 1 Copyright (c) 2005,2007 Joerg Wunsch
02 2All rights reserved. 03 3
04 4Portions of documentation Copyright (c) 1991, 1993
05 5The Regents of the University of California.
06 607 7All rights reserved.
08 809 9Redistribution and use in source and binary forms, with or without
10 10modification, are permitted provided that the following conditions are met:
11 1112 12* Redistributions of source code must retain the above copyright
13 13notice, this list of conditions and the following disclaimer.
14 1415 15* Redistributions in binary form must reproduce the above copyright
16 16notice, this list of conditions and the following disclaimer in
17 17the documentation and/or other materials provided with the
18 18distribution.
19 1920 20* Neither the name of the copyright holders nor the names of
21 21contributors may be used to endorse or promote products derived
22 22from this software without specific prior written permission.
23 2324 24THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 25AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 26IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 27ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
28 28LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 29CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 30SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 31INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 32CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 33ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 34POSSIBILITY OF SUCH DAMAGE.
35 3536 36$Id: assert.h 2290 2012-02-04 02:08:47Z dmix $
37 37*/
38 3839 39/** \file */
40 40/** \defgroup avr_assert <assert.h>: Diagnostics
41 41\code #include <assert.h> \endcode
42 4243 43This header file defines a debugging aid.
44 4445 45As there is no standard error output stream available for many
46 46applications using this library, the generation of a printable
47 47error message is not enabled by default. These messages will
48 48only be generated if the application defines the macro
49 4950 50\code __ASSERT_USE_STDERR \endcode
51 5152 52before including the \c <assert.h> header file. By default,
53 53only abort() will be called to halt the application.
54 54*/
55 5556 56/*@{*/
57 5758 58/*
59 59* The ability to include this file (with or without NDEBUG) is a
60 60* feature.
61 61*/
62 6263 63#undef assert
64 6465 65#include <stdlib.h>
66 6667 67#if defined(__DOXYGEN__)
68 68/**
69 69* \def assert
70 70* \param expression Expression to test for.
71 71*
72 72* The assert() macro tests the given expression and if it is false,
73 73* the calling process is terminated. A diagnostic message is written
74 74* to stderr and the function abort() is called, effectively
75 75* terminating the program.
76 76*
77 77* If expression is true, the assert() macro does nothing.
78 78*
79 79* The assert() macro may be removed at compile time by defining
80 80* NDEBUG as a macro (e.g., by using the compiler option -DNDEBUG).
81 81*/
82 82# define assert(expression)
83 8384 84#else /* !DOXYGEN */
85 8586 86# if defined(NDEBUG)
87 87# define assert(e) ((void)0)
88 88# else /* !NDEBUG */
89 89# if defined(__ASSERT_USE_STDERR)
90 90# define assert(e) ((e) ? (void)0 : \
91 91__assert(__func__, __FILE__, __LINE__, #e))
92 92# else /* !__ASSERT_USE_STDERR */
93 93# define assert(e) ((e) ? (void)0 : abort())
94 94# endif /* __ASSERT_USE_STDERR */
95 95# endif /* NDEBUG */
96 96#endif /* DOXYGEN */
97 9798 98#ifdef __cplusplus
99 99extern "C" {
100100#endif
101 101102 102#if !defined(__DOXYGEN__)
103 103104 104extern void __assert(const char *__func, const char *__file,
105105int __lineno, const
char *__sexp);
106106107 107#endif /* not __DOXYGEN__ */
108 108109 109#ifdef __cplusplus
110 110}
111 111#endif
112 112113 113/*@}*/
114 114/* EOF */
stdlib.h