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