PIPS
newgen_assert.h
Go to the documentation of this file.
1
/*
2
3
$Id: newgen_assert.h 1357 2016-03-02 08:18:50Z coelho $
4
5
Copyright 1989-2016 MINES ParisTech
6
7
This file is part of NewGen.
8
9
NewGen is free software: you can redistribute it and/or modify it under the
10
terms of the GNU General Public License as published by the Free Software
11
Foundation, either version 3 of the License, or any later version.
12
13
NewGen is distributed in the hope that it will be useful, but WITHOUT ANY
14
WARRANTY; without even the implied warranty of MERCHANTABILITY or
15
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
16
License for more details.
17
18
You should have received a copy of the GNU General Public License along with
19
NewGen. If not, see <http://www.gnu.org/licenses/>.
20
21
*/
22
/*
23
abort version of assert.
24
the message generates the function name if possible.
25
message_assert prints a message before aborting
26
*/
27
28
#ifdef __GNUC__
29
#define _newgen_assert_message \
30
"[%s] (%s:%d) assertion failed\n"
, __FUNCTION__, __FILE__, __LINE__
31
#else
32
#define _newgen_assert_message \
33
"Assertion failed (%s:%d)\n"
, __FILE__, __LINE__
34
#endif
35
36
#undef assert
37
#ifdef NDEBUG
38
#define assert(ex)
39
#define message_assert(msg, ex)
40
#else
41
#define assert(ex) { \
42
if (!(ex)) { \
43
(void) fprintf(stderr, _newgen_assert_message); \
44
(void) abort(); \
45
} \
46
}
47
#define message_assert(msg, ex) { \
48
if (!(ex)) { \
49
(void) fprintf(stderr, _newgen_assert_message); \
50
(void) fprintf(stderr, "\n %s not verified\n\n"
, msg); \
51
(void) abort(); \
52
} \
53
}
54
#endif
/* NDEBUG */
55
56
/* That is all
57
*/
newgen
src
genC
newgen_assert.h
Generated on Thu Sep 26 2024 22:11:31 for PIPS by
1.9.1