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