xref: /386bsd/usr/include/nonstd/gnu/g++/assert.h (revision a2142627)
1 // This may look like C code, but it is really -*- C++ -*-
2 /*
3 Copyright (C) 1988 Free Software Foundation
4 
5 This file is part of GNU CC.
6 
7 GNU CC is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY.  No author or distributor
9 accepts responsibility to anyone for the consequences of using it
10 or for whether it serves any particular purpose or works at all,
11 unless he says so in writing.  Refer to the GNU CC General Public
12 License for full details.
13 
14 Everyone is granted permission to copy, modify and redistribute
15 GNU CC, but only under the conditions described in the
16 GNU CC General Public License.   A copy of this license is
17 supposed to have been given to you along with GNU CC so you
18 can know your rights and responsibilities.  It should be in a
19 file named COPYING.  Among other things, the copyright notice
20 and this notice must be preserved on all copies.
21 */
22 
23 /* Allow this file to be included multiple times
24    with different settings of NDEBUG.  */
25 #undef assert
26 #undef assertval
27 
28 #ifdef NDEBUG
29 #define assert(ignore)
30 #define assertval(ex)  (ex)
31 #else
32 
33 extern "C" void __eprintf (char*, int, char*);		/* Defined in gnulib */
34 extern "C" volatile void   abort();
35 
36 #define assert(ex) \
37         ((ex) ? 1 : \
38               (__eprintf("Failed assertion " #ex " at line %d of `%s'.\n", \
39                __LINE__, __FILE__), abort (), 0))
40 #define assertval(ex) \
41         ((ex) ? 1 : \
42               (__eprintf("Failed assertion " #ex " at line %d of `%s'.\n", \
43                __LINE__, __FILE__), abort (), 0))
44 
45 #endif NDEBUG
46