~pac72/ubuntu/lucid/ddd/devel

« back to all changes in this revision

Viewing changes to ddd/assert.h

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Schepler
  • Date: 2004-07-22 03:49:37 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20040722034937-cysl08t1jvba4jrx
Tags: 1:3.3.9-3
USERINFO has been renamed to USERINFO.txt; adjust debian/rules code
to match, to get correct information on the About DDD dialog.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// $Id: assert.h,v 1.10 2000/05/29 14:07:25 andreas Exp $
 
1
// $Id$
2
2
// own assert() macros
3
3
// built on libg++-assert.h and making sure top-level abort() is called
4
4
 
5
5
// Copyright (C) 1995-1998 Technische Universitaet Braunschweig, Germany.
 
6
// Copyright (C) 2004 Free Software Foundation, USA.
6
7
// Written by Andreas Zeller <zeller@gnu.org>.
7
8
// 
8
9
// This file is part of DDD.
30
31
// Allow this file to be included multiple times with different
31
32
// settings of NDEBUG.
32
33
 
33
 
#if NDEBUG
 
34
#ifdef NDEBUG
34
35
#undef assert
35
36
#undef _assert_fn
36
37
#define assert(ignore)
41
42
#include "config.h"             // HAVE_PRETTY_FUNCTION
42
43
#endif
43
44
 
44
 
#include <stdlib.h>             // abort()
45
 
#include <iostream.h>
 
45
#include "casts.h"
 
46
 
 
47
#if defined __cplusplus
 
48
# define _ASSERT_VOID_CAST(x) STATIC_CAST(void,x)
 
49
#else
 
50
# define _ASSERT_VOID_CAST(x) (void)(x)
 
51
#endif
 
52
 
 
53
#include "attribute.h"
 
54
void ddd_assert_fail (const char *assertion, const char *file,
 
55
                      unsigned int line, const char *function)
 
56
     ATTRIBUTE_NORETURN;
46
57
 
47
58
#undef assert
48
59
#undef _assert_fn
49
60
 
50
61
#if HAVE_PRETTY_FUNCTION
51
 
#define _assert_fn \
52
 
"\n" << __FILE__ << ": In function `" << __PRETTY_FUNCTION__ << "':"
 
62
#define _assert_fn __PRETTY_FUNCTION__
53
63
#else // !HAVE_PRETTY_FUNCTION
54
64
#define _assert_fn ""
55
65
#endif // !HAVE_PRETTY_FUNCTION
56
66
 
57
67
#define assert(ex) \
58
 
((ex) ? 1 : (cerr << _assert_fn << "\n" << __FILE__ << ":" << __LINE__ \
59
 
                  << ": assertion `" #ex "' failed\n", \
60
 
                  ::abort(), 0))
 
68
_ASSERT_VOID_CAST(unlikely(ex) ? \
 
69
  0 : \
 
70
  (ddd_assert_fail (#ex, __FILE__, __LINE__, _assert_fn), 0) \
 
71
  )
61
72
 
62
73
#endif // !NDEBUG