OLD | NEW |
1 /* GDB-friendly replacement for <assert.h>. | 1 /* GDB-friendly replacement for <assert.h>. |
2 Copyright (C) 2000-2001, 2007-2012 Free Software Foundation, Inc. | 2 Copyright (C) 2000-2001, 2007-2012 Free Software Foundation, Inc. |
3 | 3 |
4 This file is part of GDB. | 4 This file is part of GDB. |
5 | 5 |
6 This program is free software; you can redistribute it and/or modify | 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 | 7 it under the terms of the GNU General Public License as published by |
8 the Free Software Foundation; either version 3 of the License, or | 8 the Free Software Foundation; either version 3 of the License, or |
9 (at your option) any later version. | 9 (at your option) any later version. |
10 | 10 |
11 This program is distributed in the hope that it will be useful, | 11 This program is distributed in the hope that it will be useful, |
12 but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 GNU General Public License for more details. | 14 GNU General Public License for more details. |
15 | 15 |
16 You should have received a copy of the GNU General Public License | 16 You should have received a copy of the GNU General Public License |
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */ | 17 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
18 | 18 |
19 #ifndef GDB_ASSERT_H | 19 #ifndef GDB_ASSERT_H |
20 #define GDB_ASSERT_H | 20 #define GDB_ASSERT_H |
21 | 21 |
22 /* A static assertion. This will cause a compile-time error if EXPR, | 22 /* A static assertion. This will cause a compile-time error if EXPR, |
23 which must be a compile-time constant, is false. */ | 23 which must be a compile-time constant, is false. */ |
24 | 24 |
25 #define static_assert(expr) \ | 25 #define gdb_static_assert(expr) \ |
26 extern int never_defined_just_used_for_checking[(expr) ? 1 : -1] | 26 extern int never_defined_just_used_for_checking[(expr) ? 1 : -1] |
27 | 27 |
28 /* PRAGMATICS: "gdb_assert.h":gdb_assert() is a lower case (rather | 28 /* PRAGMATICS: "gdb_assert.h":gdb_assert() is a lower case (rather |
29 than upper case) macro since that provides the closest fit to the | 29 than upper case) macro since that provides the closest fit to the |
30 existing lower case macro <assert.h>:assert() that it is | 30 existing lower case macro <assert.h>:assert() that it is |
31 replacing. */ | 31 replacing. */ |
32 | 32 |
33 #define gdb_assert(expr) \ | 33 #define gdb_assert(expr) \ |
34 ((void) ((expr) ? 0 : \ | 34 ((void) ((expr) ? 0 : \ |
35 (gdb_assert_fail (#expr, __FILE__, __LINE__, ASSERT_FUNCTION), 0))) | 35 (gdb_assert_fail (#expr, __FILE__, __LINE__, ASSERT_FUNCTION), 0))) |
(...skipping 28 matching lines...) Expand all Loading... |
64 | 64 |
65 #if defined (ASSERT_FUNCTION) | 65 #if defined (ASSERT_FUNCTION) |
66 #define gdb_assert_not_reached(message) \ | 66 #define gdb_assert_not_reached(message) \ |
67 internal_error (__FILE__, __LINE__, "%s: %s", ASSERT_FUNCTION, _(message)) | 67 internal_error (__FILE__, __LINE__, "%s: %s", ASSERT_FUNCTION, _(message)) |
68 #else | 68 #else |
69 #define gdb_assert_not_reached(message) \ | 69 #define gdb_assert_not_reached(message) \ |
70 internal_error (__FILE__, __LINE__, _(message)) | 70 internal_error (__FILE__, __LINE__, _(message)) |
71 #endif | 71 #endif |
72 | 72 |
73 #endif /* gdb_assert.h */ | 73 #endif /* gdb_assert.h */ |
OLD | NEW |