MPHELL  4.0.0
mphell-errors.h
Go to the documentation of this file.
1 /*
2  MPHELL-4.0
3  Author(s): The MPHELL team
4 
5  (C) Copyright 2015-2018 - Institut Fourier / Univ. Grenoble Alpes (France)
6 
7  This file is part of the MPHELL Library.
8  MPHELL is free software: you can redistribute it and/or modify
9  it under the terms of the GNU Lesser General Public License as published by
10  the Free Software Foundation, version 3 of the License.
11 
12  MPHELL is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU Lesser General Public License for more details.
16 
17  You should have received a copy of the GNU Lesser General Public License
18  along with MPHELL. If not, see <http://www.gnu.org/licenses/>.
19 */
20 
26 #ifndef ERRORS_H
27 #define ERRORS_H
28 
29 #include <stdio.h>
30 #include <stdlib.h>
31 
32 #include "mphell-define.h"
33 
34 #ifdef __LINE__
35 #define MPHELL_ASSERT_LINE __LINE__
36 #else
37 #define MPHELL_ASSERT_LINE -1
38 #endif
39 
40 #ifdef __FILE__
41 #define MPHELL_ASSERT_FILE __FILE__
42 #else
43 #define MPHELL_ASSERT_FILE ""
44 #endif
45 
46 #define MPHELL_ASSERT_FAIL(info) mphell_assert_error (MPHELL_ASSERT_FILE, \
47  MPHELL_ASSERT_LINE, info)
48 
49 #define MPHELL_ASSERT_ALWAYS(expr, info) \
50  do { \
51  if (!(expr)) \
52  MPHELL_ASSERT_FAIL (info); \
53  } while (0)
54 
55 
56 #if MPHELL_USE_ASSERT == 1
57 #define MPHELL_ASSERT(expr, info) MPHELL_ASSERT_ALWAYS (expr, info)
58 #else
59 #define MPHELL_ASSERT(expr, info) do {} while (0)
60 #endif
61 
67 {
72 };
73 
79 
84 typedef struct
85 {
87  char *info;
89 
95 
103 void
104 mphell_assert_error (const char *filename, int line, const char *expr);
105 
111 void
112 mphell_error (char *expr);
113 
119 void
120 mphell_error_free (char *expr);
121 
122 #endif
void mphell_error(char *expr)
Write in stderr, filename, line and expr, free mphell.
Definition: mphell-errors.c:45
enum mphell_status_flag_enum mphell_status_flag
Enumerate status flag.
Definition: mphell-errors.h:78
void mphell_assert_error(const char *filename, int line, const char *expr)
Write in stderr, filename, line and expr, free mphell.
Definition: mphell-errors.c:29
mphell_status_t mphell_status[1]
The status is a couple (flag, information)
Definition: mphell-errors.h:94
void mphell_error_free(char *expr)
Write in stderr, filename, line and expr, free expr and mphell.
Definition: mphell-errors.c:61
mphell_status_flag flag
Definition: mphell-errors.h:86
Wrap the config.h generated by configure.ac.
mphell_status_flag_enum
Enumerate status flag.
Definition: mphell-errors.h:66
The status is a couple (flag, information)
Definition: mphell-errors.h:84