Commit | Line | Data |
---|---|---|
d44e3c4f | 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 | * | |
12 | ******************************************************************************/ | |
970ed795 EL |
13 | #ifndef _langviz_error_H |
14 | #define _langviz_error_H | |
15 | ||
16 | #ifndef __GNUC__ | |
17 | /** If a C compiler other than GCC is used the macro below will substitute all | |
18 | * GCC-specific non-standard attributes with an empty string. */ | |
19 | #ifndef __attribute__ | |
20 | #define __attribute__(arg) | |
21 | #endif | |
22 | #endif | |
23 | ||
24 | #ifdef __cplusplus | |
25 | extern "C" { | |
26 | #endif | |
27 | ||
28 | /** | |
29 | * | |
30 | * Verbosity level (bitmask). | |
31 | * | |
32 | * Meaning of bits: | |
33 | * 1: "not supported" messages | |
34 | * 2: warning | |
35 | * 4: notify | |
36 | * 8: debug 0 | |
37 | * 16: debug 1 | |
38 | * 32: debug 2 | |
39 | * | |
40 | * Debug bits define the debug level in the interval 0..7; 0 means no | |
41 | * debug messages, 7 means very verbose. | |
42 | */ | |
43 | extern unsigned verb_level; | |
44 | ||
45 | /** | |
46 | * The argv[0] of main, i.e. the programname. | |
47 | */ | |
48 | extern const char *argv0; | |
49 | ||
50 | /** | |
51 | * FATAL_ERROR(const char *fmt, ...) macro prints a formatted error message | |
52 | * to stderr and aborts execution. It calls the fatal_error function with | |
53 | * appropriate file name and line number information | |
54 | */ | |
55 | #if defined (__GNUC__) | |
56 | /** | |
57 | * The preprocessors of GCC versions 2.95.3 or earlier do not support the | |
58 | * standard notation for varadic macros in C++ mode. | |
59 | * Therefore this proprietary notation is used with GCC. | |
60 | */ | |
61 | #define FATAL_ERROR(fmt, args...) \ | |
62 | (fatal_error(__FILE__, __LINE__, fmt, ## args)) | |
63 | #else | |
64 | /** | |
65 | * This is the standard notation. | |
66 | */ | |
67 | #define FATAL_ERROR(...) \ | |
68 | (fatal_error(__FILE__, __LINE__, __VA_ARGS__)) | |
69 | #endif | |
70 | ||
71 | /** | |
72 | * fatal_error function, which is not supposed to be called directly. | |
73 | */ | |
74 | extern void fatal_error(const char *filename, int lineno, const char *fmt, ...) | |
75 | __attribute__ ((__format__ (__printf__, 3, 4), __noreturn__)); | |
76 | ||
77 | /** | |
78 | * Prints a formatted error message to stderr. | |
79 | */ | |
80 | extern void ERROR(const char *fmt, ...) | |
81 | __attribute__ ((__format__ (__printf__, 1, 2))); | |
82 | ||
83 | /** | |
84 | * Prints a formatted warning message to stderr. | |
85 | */ | |
86 | extern void WARNING(const char *fmt, ...) | |
87 | __attribute__ ((__format__ (__printf__, 1, 2))); | |
88 | ||
89 | /** | |
90 | * Prints a formatted warning message to stderr: "Warning: Not supported: %s". | |
91 | */ | |
92 | extern void NOTSUPP(const char *fmt, ...) | |
93 | __attribute__ ((__format__ (__printf__, 1, 2))); | |
94 | ||
95 | /** | |
96 | * Prints a formatted notify message to stderr. | |
97 | */ | |
98 | extern void NOTIFY(const char *fmt, ...) | |
99 | __attribute__ ((__format__ (__printf__, 1, 2))); | |
100 | ||
101 | /** | |
102 | * Prints a formatted debug message to stderr. | |
103 | */ | |
104 | extern void DEBUG(unsigned level, const char *fmt, ...) | |
105 | __attribute__ ((__format__ (__printf__, 2, 3))); | |
106 | ||
107 | ||
108 | #ifdef __cplusplus | |
109 | } | |
110 | #endif | |
111 | ||
112 | #endif // _langviz_error_H |