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