* tui-hooks.c: Update include order.
[deliverable/binutils-gdb.git] / gdb / gdb_assert.h
CommitLineData
6751bfc9 1/* GDB-friendly replacement for <assert.h>.
8e65ff28 2 Copyright 2000, 2001 Free Software Foundation, Inc.
6751bfc9
MK
3
4 This file is part of GDB.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
20
21#ifndef GDB_ASSERT_H
22#define GDB_ASSERT_H
23
38266776
AC
24/* PRAGMATICS: "gdb_assert.h":gdb_assert() is a lower case (rather
25 than upper case) macro since that provides the closest fit to the
26 existing lower case macro <assert.h>:assert() that it is
27 replacing. */
28
6751bfc9
MK
29#define gdb_assert(expr) \
30 ((void) ((expr) ? 0 : \
31 (gdb_assert_fail (#expr, __FILE__, __LINE__, ASSERT_FUNCTION), 0)))
32
33/* Version 2.4 and later of GCC define a magical variable `__PRETTY_FUNCTION__'
34 which contains the name of the function currently being defined.
35 This is broken in G++ before version 2.6.
36 C9x has a similar variable called __func__, but prefer the GCC one since
37 it demangles C++ function names. */
38#if (GCC_VERSION >= 2004)
39#define ASSERT_FUNCTION __PRETTY_FUNCTION__
40#else
41#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
42#define ASSERT_FUNCTION __func__
6751bfc9
MK
43#endif
44#endif
45
46/* This prints an "Assertion failed" message, aksing the user if they
47 want to continue, dump core, or just exit. */
93ec1121
AC
48#if defined (ASSERT_FUNCTION)
49#define gdb_assert_fail(assertion, file, line, function) \
50 internal_error (file, line, "%s: Assertion `%s' failed.", \
51 function, assertion)
52#else
6751bfc9 53#define gdb_assert_fail(assertion, file, line, function) \
93ec1121 54 internal_error (file, line, "Assertion `%s' failed.", \
6751bfc9 55 assertion)
93ec1121 56#endif
6751bfc9
MK
57
58#endif /* gdb_assert.h */
This page took 0.225939 seconds and 4 git commands to generate.