Newer
Older
/******************************************************************************
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
*
* Contributors:
* Balasko, Jeno
* Forstner, Matyas
* Gecse, Roland
* Kremer, Peter
* Raduly, Csaba
* Szabo, Janos Zoltan – initial implementation
*
******************************************************************************/
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#ifndef _ERROR_H
#define _ERROR_H
#ifndef __GNUC__
/** If a C compiler other than GCC is used the macro below will substitute all
* GCC-specific non-standard attributes with an empty string. */
#ifndef __attribute__
#define __attribute__(arg)
#endif
#endif
#ifdef __cplusplus
extern "C" {
#endif
/**
* \defgroup error Error reporting functions
* \author Roland Gecse <ethrge@eth.ericsson.se>
*
* @{
*/
/**
*
* Verbosity level (bitmask).
*
* Meaning of bits:
* 1: "not supported" messages
* 2: warning
* 4: notify
* 8: debug 0
* 16: debug 1
* 32: debug 2
*
* Debug bits define the debug level in the interval 0..7; 0 means no
* debug messages, 7 means very verbose.
*/
extern unsigned verb_level;
/**
* The argv[0] of main, i.e. the program name.
*/
extern const char *argv0;
/**
* FATAL_ERROR(const char *fmt, ...) macro prints a formatted error message
* to stderr and aborts execution. It calls the fatal_error function with
* appropriate file name and line number information
*/
#if defined(__GNUC__) && __GNUC__ < 3
/**
* The preprocessors of GCC versions earlier than 3.0 do not support the
* standard notation for variadic macros in C++ mode.
* Therefore this proprietary notation is used with those old GCC versions.
*/
#define FATAL_ERROR(fmt, args...) \
(fatal_error(__FILE__, __LINE__, fmt, ## args))
#else
/**
* This is the standard notation.
*/
#define FATAL_ERROR(...) \
(fatal_error(__FILE__, __LINE__, __VA_ARGS__))
#endif
/**
* fatal_error function, which is not supposed to be called directly.
*/
extern void fatal_error(const char *filename, int lineno, const char *fmt, ...)
__attribute__ ((__format__ (__printf__, 3, 4), __noreturn__));
/**
* Prints a formatted error message to stderr.
* Used for reporting system-related errors, e.g. file not found etc.
* Compiler errors are reported through Common::Location::error.
*/
extern void ERROR(const char *fmt, ...)
__attribute__ ((__format__ (__printf__, 1, 2)));
/**
* Prints a formatted warning message to stderr.
*/
extern void WARNING(const char *fmt, ...)
__attribute__ ((__format__ (__printf__, 1, 2)));
/**
* Prints a formatted warning message to stderr: "Warning: Not supported: %s".
*/
extern void NOTSUPP(const char *fmt, ...)
__attribute__ ((__format__ (__printf__, 1, 2)));
/**
* Prints a formatted notify message to stderr.
*/
extern void NOTIFY(const char *fmt, ...)
__attribute__ ((__format__ (__printf__, 1, 2)));
/**
* Prints a formatted debug message to stderr.
*/
extern void DEBUG(unsigned level, const char *fmt, ...)
__attribute__ ((__format__ (__printf__, 2, 3)));
/**
* Returns the current value of the error counter.
*/
extern unsigned int get_error_count(void);
/**
* Returns the current value of the warning counter.
*/
extern unsigned int get_warning_count(void);
/** @} end of error group */
#ifdef __cplusplus
}
#endif
#endif /* _ERROR_H */