PIPS
linear_assert.h
Go to the documentation of this file.
1
/*
2
3
$Id: linear_assert.h 1669 2019-06-26 17:24:57Z coelho $
4
5
Copyright 1989-2016 MINES ParisTech
6
7
This file is part of Linear/C3 Library.
8
9
Linear/C3 Library is free software: you can redistribute it and/or modify it
10
under the terms of the GNU Lesser General Public License as published by
11
the Free Software Foundation, either version 3 of the License, or
12
any later version.
13
14
Linear/C3 Library is distributed in the hope that it will be useful, but WITHOUT ANY
15
WARRANTY; without even the implied warranty of MERCHANTABILITY or
16
FITNESS FOR A PARTICULAR PURPOSE.
17
18
See the GNU Lesser General Public License for more details.
19
20
You should have received a copy of the GNU Lesser General Public License
21
along with Linear/C3 Library. If not, see <http://www.gnu.org/licenses/>.
22
23
*/
24
25
/* "abort" version of "/usr/include/assert.h", and assert with a message.
26
* breakpoint on abort() to catch an issue.
27
* put here so as to mask the "/usr/include" version.
28
*
29
* You need an include of <stdio.h> and <stdlib.h> to use it.
30
*/
31
32
#ifndef __linear_assert_included__
33
#define __linear_assert_included__
34
35
#ifdef __GNUC__
36
#define _linear_assert_message \
37
"[%s] (%s:%d) assertion failed\n"
, __FUNCTION__, __FILE__, __LINE__
38
#else
39
#define _linear_assert_message \
40
"Assertion failed (%s:%d)\n"
, __FILE__, __LINE__
41
#endif
42
43
#undef assert
44
#ifdef NDEBUG
45
#define assert(ex)
46
#define linear_assert(msg, ex)
47
#else
48
extern
int
linear_assertion_result
;
49
#define assert(ex) \
50
linear_assertion_result = ((ex)? 1: (fprintf(stderr, _linear_assert_message), abort(), 0))
51
#define linear_assert(msg, ex) { \
52
if (!(ex)) { \
53
(void) fprintf(stderr, _linear_assert_message); \
54
(void) fprintf(stderr, "\n %s not verified\n\n"
, msg); \
55
(void) abort(); \
56
} \
57
}
58
#endif
// NDEBUG
59
#endif
// __linear_assert_included__
linear_assertion_result
int linear_assertion_result
errors.c
Definition:
errors.c:43
linear
src
arithmetique
linear_assert.h
Generated on Thu Sep 26 2024 22:11:28 for PIPS by
1.9.1