2 * SDCCerr - Standard error handler
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Library General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 #define USE_STDOUT_FOR_ERRORS 0
26 #if USE_STDOUT_FOR_ERRORS
27 #define DEFAULT_ERROR_OUT stdout
29 #define DEFAULT_ERROR_OUT stderr
33 ERROR_LOG_LEVEL logLevel;
35 int style; /* 1=MSVC */
38 extern char *filename ;
40 extern int fatalError ;
42 /* Currently the errIndex field must match the position of the
43 * entry in the array. It is only included in order to make
44 * human error lookup easier.
49 ERROR_LOG_LEVEL errType;
53 { E_DUPLICATE, ERROR_LEVEL_ERROR,
54 "Duplicate symbol '%s', symbol IGNORED" },
55 { E_SYNTAX_ERROR, ERROR_LEVEL_ERROR,
56 "Syntax error, declaration ignored at '%s'" },
57 { E_CONST_EXPECTED, ERROR_LEVEL_ERROR,
58 "Initializer element is not constant" },
59 { E_OUT_OF_MEM, ERROR_LEVEL_ERROR,
60 "'malloc' failed file '%s' for size %ld" },
61 { E_FILE_OPEN_ERR, ERROR_LEVEL_ERROR,
62 "'fopen' failed on file '%s'" },
63 { E_INVALID_OCLASS, ERROR_LEVEL_ERROR,
64 "Internal Error Oclass invalid '%s'" },
65 { E_CANNOT_ALLOC, ERROR_LEVEL_ERROR,
66 "Cannot allocate variable '%s'." },
67 { E_OLD_STYLE, ERROR_LEVEL_ERROR,
68 "Old style C declaration. IGNORED '%s'" },
69 { E_STACK_OUT, ERROR_LEVEL_ERROR,
70 "Out of stack Space. '%s' not allocated" },
71 { E_INTERNAL_ERROR, ERROR_LEVEL_ERROR,
72 "FATAL Compiler Internal Error in file '%s' line number '%d' : %s \n"
73 "Contact Author with source code" },
74 { E_LVALUE_REQUIRED, ERROR_LEVEL_ERROR,
75 "'lvalue' required for '%s' operation." },
76 { E_TMPFILE_FAILED, ERROR_LEVEL_ERROR,
77 "Creation of temp file failed" },
78 { E_FUNCTION_EXPECTED, ERROR_LEVEL_ERROR,
79 "called object is not a function" },
80 { E_USING_ERROR, ERROR_LEVEL_ERROR,
81 "'using', 'interrupt' or 'reentrant' must follow a function definiton.'%s'" },
82 { E_SFR_INIT, ERROR_LEVEL_ERROR,
83 "Absolute address & initial value both cannot be specified for\n"
84 " a 'sfr','sbit' storage class, initial value ignored '%s'" },
85 { W_INIT_IGNORED, ERROR_LEVEL_WARNING,
86 "Variable in the storage class cannot be initialized.'%s'" },
87 { E_AUTO_ASSUMED, ERROR_LEVEL_ERROR,
88 "variable '%s' must be static to have storage class in reentrant function" },
89 { E_AUTO_ABSA, ERROR_LEVEL_ERROR,
90 "absolute address not allowed for automatic var '%s' in reentrant function " },
91 { W_INIT_WRONG, ERROR_LEVEL_WARNING,
92 "Initializer different levels of indirections" },
93 { E_FUNC_REDEF, ERROR_LEVEL_ERROR,
94 "Function name '%s' redefined " },
95 { E_ID_UNDEF, ERROR_LEVEL_ERROR,
96 "Undefined identifier '%s'" },
97 { W_STACK_OVERFLOW, ERROR_LEVEL_WARNING,
98 "stack exceeds 256 bytes for function '%s'" },
99 { E_NEED_ARRAY_PTR, ERROR_LEVEL_ERROR,
100 "Array or pointer required for '%s' operation " },
101 { E_IDX_NOT_INT, ERROR_LEVEL_ERROR,
102 "Array index not an integer" },
103 { W_IDX_OUT_OF_BOUNDS, ERROR_LEVEL_WARNING,
104 "index %i is outside of the array bounds (array size is %i)" },
105 { E_STRUCT_UNION, ERROR_LEVEL_ERROR,
106 "Structure/Union expected left of '.%s'" },
107 { E_NOT_MEMBER, ERROR_LEVEL_ERROR,
108 "'%s' not a structure/union member" },
109 { E_PTR_REQD, ERROR_LEVEL_ERROR,
110 "Pointer required" },
111 { E_UNARY_OP, ERROR_LEVEL_ERROR,
112 "'unary %c': illegal operand" },
113 { E_CONV_ERR, ERROR_LEVEL_ERROR,
114 "convertion error: integral promotion failed" },
115 { E_INT_REQD, ERROR_LEVEL_ERROR,
116 "type must be INT for bit field definition" },
117 { E_BITFLD_SIZE, ERROR_LEVEL_ERROR,
118 "bit field size cannot be greater than int (%d bits)" },
119 { W_TRUNCATION, ERROR_LEVEL_WARNING,
120 "high order truncation might occur" },
121 { E_CODE_WRITE, ERROR_LEVEL_ERROR,
122 "Attempt to assign value to a constant variable (%s)" },
123 { E_LVALUE_CONST, ERROR_LEVEL_ERROR,
124 "Lvalue specifies constant object" },
125 { E_ILLEGAL_ADDR, ERROR_LEVEL_ERROR,
126 "'&' illegal operand , %s" },
127 { E_CAST_ILLEGAL, ERROR_LEVEL_ERROR,
128 "illegal cast (cast cannot be aggregate)" },
129 { E_MULT_INTEGRAL, ERROR_LEVEL_ERROR,
131 { E_ARG_ERROR, ERROR_LEVEL_ERROR,
132 "Argument count error, argument ignored" },
133 { E_ARG_COUNT, ERROR_LEVEL_ERROR,
134 "Function was expecting more arguments" },
135 { E_FUNC_EXPECTED, ERROR_LEVEL_ERROR,
136 "Function name expected '%s'. ANSI style declaration REQUIRED" },
137 { E_PLUS_INVALID, ERROR_LEVEL_ERROR,
138 "invalid operand '%s'" },
139 { E_PTR_PLUS_PTR, ERROR_LEVEL_ERROR,
140 "pointer + pointer invalid" },
141 { E_SHIFT_OP_INVALID, ERROR_LEVEL_ERROR,
142 "invalid operand for shift operator" },
143 { E_COMPARE_OP, ERROR_LEVEL_ERROR,
144 "compare operand cannot be struct/union" },
145 { E_BITWISE_OP, ERROR_LEVEL_ERROR,
146 "operand invalid for bitwise operation" },
147 { E_ANDOR_OP, ERROR_LEVEL_ERROR,
148 "Invalid operand for '&&' or '||'" },
149 { E_TYPE_MISMATCH, ERROR_LEVEL_ERROR,
150 "indirections to different types %s %s " },
151 { E_AGGR_ASSIGN, ERROR_LEVEL_ERROR,
152 "cannot assign values to aggregates" },
153 { E_ARRAY_DIRECT, ERROR_LEVEL_ERROR,
154 "bit Arrays can be accessed by literal index only" },
155 { E_BIT_ARRAY, ERROR_LEVEL_ERROR,
156 "Array or Pointer to bit|sbit|sfr not allowed.'%s'" },
157 { E_DUPLICATE_TYPEDEF, ERROR_LEVEL_ERROR,
158 "typedef/enum '%s' duplicate. Previous definiton Ignored" },
159 { E_ARG_TYPE, ERROR_LEVEL_ERROR,
160 "Actual Argument type different from declaration %d" },
161 { E_RET_VALUE, ERROR_LEVEL_ERROR,
162 "Function return value mismatch" },
163 { E_FUNC_AGGR, ERROR_LEVEL_ERROR,
164 "Function cannot return aggregate. Func body ignored" },
165 { E_FUNC_DEF, ERROR_LEVEL_ERROR,
166 "ANSI Style declaration needed" },
167 { E_DUPLICATE_LABEL, ERROR_LEVEL_ERROR,
168 "Duplicate label '%s'" },
169 { E_LABEL_UNDEF, ERROR_LEVEL_ERROR,
170 "Label undefined '%s'" },
171 { E_FUNC_VOID, ERROR_LEVEL_ERROR,
172 "void function returning value" },
173 { W_VOID_FUNC, ERROR_LEVEL_WARNING,
174 "function '%s' must return value" },
175 { W_RETURN_MISMATCH, ERROR_LEVEL_WARNING,
176 "function return value mismatch" },
177 { E_CASE_CONTEXT, ERROR_LEVEL_ERROR,
178 "'case/default' found without 'switch'. Statement ignored" },
179 { E_CASE_CONSTANT, ERROR_LEVEL_ERROR,
180 "'case' expression not constant. Statement ignored" },
181 { E_BREAK_CONTEXT, ERROR_LEVEL_ERROR,
182 "'break/continue' statement out of context" },
183 { E_SWITCH_AGGR, ERROR_LEVEL_ERROR,
184 "nonintegral used in switch expression" },
185 { E_FUNC_BODY, ERROR_LEVEL_ERROR,
186 "function '%s' already has body" },
187 { E_UNKNOWN_SIZE, ERROR_LEVEL_ERROR,
188 "attempt to allocate variable of unknown size '%s'" },
189 { E_AUTO_AGGR_INIT, ERROR_LEVEL_ERROR,
190 "aggregate 'auto' variable '%s' cannot be initialized" },
191 { E_INIT_COUNT, ERROR_LEVEL_ERROR,
192 "too many initializers" },
193 { E_INIT_STRUCT, ERROR_LEVEL_ERROR,
194 "struct/union/array '%s' :initialization needs curly braces" },
195 { E_INIT_NON_ADDR, ERROR_LEVEL_ERROR,
196 "non-address initialization expression" },
197 { E_INT_DEFINED, ERROR_LEVEL_ERROR,
198 "interrupt no '%d' already has a service routine '%s'" },
199 { E_INT_ARGS, ERROR_LEVEL_ERROR,
200 "interrupt routine cannot have arguments, arguments ingored" },
201 { E_INCLUDE_MISSING, ERROR_LEVEL_ERROR,
202 "critical compiler #include file missing. " },
203 { E_NO_MAIN, ERROR_LEVEL_ERROR,
204 "function 'main' undefined" },
205 { E_EXTERN_INIT, ERROR_LEVEL_ERROR,
206 "'extern' variable '%s' cannot be initialised " },
207 { E_PRE_PROC_FAILED, ERROR_LEVEL_ERROR,
208 "Pre-Processor %s" },
209 { E_DUP_FAILED, ERROR_LEVEL_ERROR,
210 "_dup call failed" },
211 { E_INCOMPAT_TYPES, ERROR_LEVEL_ERROR,
212 "incompatible types" },
213 { W_LOOP_ELIMINATE, ERROR_LEVEL_WARNING,
214 "'while' loop with 'zero' constant. Loop eliminated" },
215 { W_NO_SIDE_EFFECTS, ERROR_LEVEL_WARNING,
216 "%s expression has NO side effects. Expr eliminated" },
217 { W_CONST_TOO_LARGE, ERROR_LEVEL_PEDANTIC,
218 "constant value '%s', out of range." },
219 { W_BAD_COMPARE, ERROR_LEVEL_WARNING,
220 "comparison will either, ALWAYs succeed or ALWAYs fail" },
221 { E_TERMINATING, ERROR_LEVEL_ERROR,
222 "Compiler Terminating , contact author with source" },
223 { W_LOCAL_NOINIT, ERROR_LEVEL_WARNING,
224 "'auto' variable '%s' may be used before initialization" },
225 { W_NO_REFERENCE, ERROR_LEVEL_WARNING,
226 "in function %s unreferenced %s : '%s'" },
227 { E_OP_UNKNOWN_SIZE, ERROR_LEVEL_ERROR,
228 "unknown size for operand" },
229 { W_LONG_UNSUPPORTED, ERROR_LEVEL_WARNING,
230 "'%s' 'long' not supported , declared as 'int'." },
231 { E_LITERAL_GENERIC, ERROR_LEVEL_ERROR,
232 //"illegal cast of LITERAL value to 'generic' pointer: assuming 'xdata' pointer" },
233 "illegal cast of LITERAL value to 'generic' pointer" },
234 { E_SFR_ADDR_RANGE, ERROR_LEVEL_ERROR,
235 "%s '%s' address out of range" },
236 { E_BITVAR_STORAGE, ERROR_LEVEL_ERROR,
237 "storage class CANNOT be specified for bit variable '%s'" },
238 { E_EXTERN_MISMATCH, ERROR_LEVEL_ERROR,
239 "extern definition for '%s' mismatches with declaration." },
240 { W_NONRENT_ARGS, ERROR_LEVEL_WARNING,
241 "Functions called via pointers must be 'reentrant' to take arguments" },
242 { W_DOUBLE_UNSUPPORTED, ERROR_LEVEL_WARNING,
243 "type 'double' not supported assuming 'float'" },
244 { W_IF_NEVER_TRUE, ERROR_LEVEL_WARNING,
245 "if-statement condition always false, if-statement not generated" },
246 { W_FUNC_NO_RETURN, ERROR_LEVEL_WARNING,
247 "no 'return' statement found for function '%s'" },
248 { W_PRE_PROC_WARNING, ERROR_LEVEL_WARNING,
249 "Pre-Processor %s" },
250 { W_STRUCT_AS_ARG, ERROR_LEVEL_WARNING,
251 "structure '%s' passed as function argument changed to pointer" },
252 { E_PREV_DEF_CONFLICT, ERROR_LEVEL_ERROR,
253 "conflict with previous definition of '%s' for attribute '%s'" },
254 { E_CODE_NO_INIT, ERROR_LEVEL_ERROR,
255 "variable '%s' declared in code space must have initialiser" },
256 { E_OPS_INTEGRAL, ERROR_LEVEL_ERROR,
257 "operands not integral for assignment operation" },
258 { E_TOO_MANY_PARMS, ERROR_LEVEL_ERROR,
259 "too many parameters " },
260 { E_TOO_FEW_PARMS, ERROR_LEVEL_ERROR,
261 "too few parameters" },
262 { E_FUNC_NO_CODE, ERROR_LEVEL_ERROR,
263 "code not generated for '%s' due to previous errors" },
264 { E_TYPE_MISMATCH_PARM, ERROR_LEVEL_ERROR,
265 "type mismatch for parameter number %d" },
266 { E_INVALID_FLOAT_CONST, ERROR_LEVEL_ERROR,
267 "invalid float constant '%s'" },
268 { E_INVALID_OP, ERROR_LEVEL_ERROR,
269 "invalid operand for '%s' operation" },
270 { E_SWITCH_NON_INTEGER, ERROR_LEVEL_ERROR,
271 "switch value not an integer" },
272 { E_CASE_NON_INTEGER, ERROR_LEVEL_ERROR,
273 "case label not an integer" },
274 { W_FUNC_TOO_LARGE, ERROR_LEVEL_WARNING,
275 "function '%s' too large for global optimization" },
276 { W_CONTROL_FLOW, ERROR_LEVEL_PEDANTIC,
277 "conditional flow changed by optimizer: so said EVELYN the modified DOG" },
278 { W_PTR_TYPE_INVALID, ERROR_LEVEL_WARNING,
279 "invalid type specifier for pointer type; specifier ignored" },
280 { W_IMPLICIT_FUNC, ERROR_LEVEL_WARNING,
281 "function '%s' implicit declaration" },
282 { W_CONTINUE, ERROR_LEVEL_WARNING,
284 { I_EXTENDED_STACK_SPILS, ERROR_LEVEL_INFO,
285 "extended stack by %d bytes for compiler temp(s) :in function '%s': %s " },
286 { W_UNKNOWN_PRAGMA, ERROR_LEVEL_WARNING,
287 "unknown or unsupported #pragma directive '%s'" },
288 { W_SHIFT_CHANGED, ERROR_LEVEL_PEDANTIC,
289 "%s shifting more than size of object changed to zero" },
290 { W_UNKNOWN_OPTION, ERROR_LEVEL_WARNING,
291 "unknown compiler option '%s' ignored" },
292 { W_UNSUPP_OPTION, ERROR_LEVEL_WARNING,
293 "option '%s' no longer supported '%s' " },
294 { W_UNKNOWN_FEXT, ERROR_LEVEL_WARNING,
295 "don't know what to do with file '%s'. file extension unsupported" },
296 { W_TOO_MANY_SRC, ERROR_LEVEL_WARNING,
297 "cannot compile more than one source file. file '%s' ignored" },
298 { I_CYCLOMATIC, ERROR_LEVEL_INFO,
299 "function '%s', # edges %d , # nodes %d , cyclomatic complexity %d" },
300 { E_DIVIDE_BY_ZERO, ERROR_LEVEL_ERROR,
301 "dividing by ZERO" },
302 { E_FUNC_BIT, ERROR_LEVEL_ERROR,
303 "function cannot return 'bit'" },
304 { E_CAST_ZERO, ERROR_LEVEL_ERROR,
305 "casting from to type 'void' is illegal" },
306 { W_CONST_RANGE, ERROR_LEVEL_WARNING,
307 "constant is out of range %s" },
308 { W_CODE_UNREACH, ERROR_LEVEL_PEDANTIC,
309 "unreachable code" },
310 { E_NONPTR2_GENPTR, ERROR_LEVEL_ERROR,
311 "non-pointer type cast to generic pointer" },
312 { W_POSSBUG, ERROR_LEVEL_WARNING,
313 "possible code generation error at line %d,\n"
314 " send source to sandeep.dutta@usa.net" },
315 { E_INCOMPAT_PTYPES, ERROR_LEVEL_ERROR,
316 "pointer types incompatible " },
317 { W_UNKNOWN_MODEL, ERROR_LEVEL_WARNING,
318 "unknown memory model at %s : %d" },
319 { E_UNKNOWN_TARGET, ERROR_LEVEL_ERROR,
320 "cannot generate code for target '%s'" },
321 { W_INDIR_BANKED, ERROR_LEVEL_WARNING,
322 "Indirect call to a banked function not implemented." },
323 { W_UNSUPPORTED_MODEL, ERROR_LEVEL_WARNING,
324 "Model '%s' not supported for %s, ignored." },
325 { W_BANKED_WITH_NONBANKED, ERROR_LEVEL_WARNING,
326 "Both banked and nonbanked attributes used. nonbanked wins." },
327 { W_BANKED_WITH_STATIC, ERROR_LEVEL_WARNING,
328 "Both banked and static used. static wins." },
329 { W_INT_TO_GEN_PTR_CAST, ERROR_LEVEL_WARNING,
330 "converting integer type to generic pointer: assuming XDATA" },
331 { W_ESC_SEQ_OOR_FOR_CHAR, ERROR_LEVEL_WARNING,
332 "escape sequence out of range for char." },
333 { E_INVALID_HEX, ERROR_LEVEL_ERROR,
334 "\\x used with no following hex digits." },
335 { W_FUNCPTR_IN_USING_ISR, ERROR_LEVEL_WARNING,
336 "call via function pointer in ISR using non-zero register bank.\n"
337 " Cannot determine which register bank to save." },
338 { E_NO_SUCH_BANK, ERROR_LEVEL_ERROR,
339 "called function uses unknown register bank %d." },
340 { E_TWO_OR_MORE_DATA_TYPES, ERROR_LEVEL_ERROR,
341 "two or more data types in declaration for '%s'" },
342 { E_LONG_OR_SHORT_INVALID, ERROR_LEVEL_ERROR,
343 "long or short specified for %s '%s'" },
344 { E_SIGNED_OR_UNSIGNED_INVALID, ERROR_LEVEL_ERROR,
345 "signed or unsigned specified for %s '%s'" },
346 { E_LONG_AND_SHORT_INVALID, ERROR_LEVEL_ERROR,
347 "both long and short specified for %s '%s'" },
348 { E_SIGNED_AND_UNSIGNED_INVALID, ERROR_LEVEL_ERROR,
349 "both signed and unsigned specified for %s '%s'" },
350 { E_TWO_OR_MORE_STORAGE_CLASSES, ERROR_LEVEL_ERROR,
351 "two or more storage classes in declaration for '%s'" },
352 { W_EXCESS_INITIALIZERS, ERROR_LEVEL_WARNING,
353 "excess elements in %s initializer after `%s'" },
354 { E_ARGUMENT_MISSING, ERROR_LEVEL_ERROR,
355 "Option %s requires an argument." },
356 { W_STRAY_BACKSLASH, ERROR_LEVEL_WARNING,
357 "stray '\\' at column %d" },
358 { W_NEWLINE_IN_STRING, ERROR_LEVEL_WARNING,
359 "newline in string constant" },
360 { E_CANNOT_USE_GENERIC_POINTER, ERROR_LEVEL_ERROR,
361 "cannot use generic pointer %s to initialize %s" },
362 { W_EXCESS_SHORT_OPTIONS, ERROR_LEVEL_WARNING,
363 "Only one short option can be specified at a time. Rest of %s ignored." },
364 { E_VOID_VALUE_USED, ERROR_LEVEL_ERROR,
365 "void value not ignored as it ought to be" },
366 { W_INTEGRAL2PTR_NOCAST, ERROR_LEVEL_WARNING,
367 "converting integral to pointer without a cast" },
368 { W_PTR2INTEGRAL_NOCAST, ERROR_LEVEL_WARNING,
369 "converting pointer to integral without a cast" },
370 { W_SYMBOL_NAME_TOO_LONG, ERROR_LEVEL_WARNING,
371 "symbol name too long, truncated to %d chars" },
372 { W_CAST_STRUCT_PTR,ERROR_LEVEL_WARNING,
373 "cast of struct %s * to struct %s * " },
374 { W_IF_ALWAYS_TRUE, ERROR_LEVEL_WARNING,
375 "if-statement condition always true, if-statement not generated" },
376 { E_PARAM_NAME_OMITTED, ERROR_LEVEL_ERROR,
377 "in function %s: name omitted for parameter %d" },
378 { W_NO_FILE_ARG_IN_C1, ERROR_LEVEL_WARNING,
379 "only standard input is compiled in c1 mode. file '%s' ignored" },
380 { E_NEED_OPT_O_IN_C1, ERROR_LEVEL_ERROR,
381 "must specify assembler file name with -o in c1 mode" },
382 { W_ILLEGAL_OPT_COMBINATION, ERROR_LEVEL_WARNING,
383 "illegal combination of options (--c1mode, -E, -S -c)" },
384 { E_DUPLICATE_MEMBER, ERROR_LEVEL_ERROR,
385 "duplicate %s member '%s'" },
386 { E_STACK_VIOLATION, ERROR_LEVEL_ERROR,
387 "'%s' internal stack %s" },
388 { W_INT_OVL, ERROR_LEVEL_PEDANTIC,
389 "integer overflow in expression" },
390 { W_USELESS_DECL, ERROR_LEVEL_WARNING,
391 "useless declaration (possible use of keyword as variable name)" },
392 { E_INT_BAD_INTNO, ERROR_LEVEL_ERROR,
393 "interrupt number '%u' is not valid" },
394 { W_BITFLD_NAMED, ERROR_LEVEL_WARNING,
395 "ignoring declarator of 0 length bitfield" },
396 { E_FUNC_ATTR, ERROR_LEVEL_ERROR,
397 "function attribute following non-function declaration"},
398 { W_SAVE_RESTORE, ERROR_LEVEL_PEDANTIC,
399 "unmatched #pragma save and #pragma restore" },
400 { E_INVALID_CRITICAL, ERROR_LEVEL_ERROR,
401 "not allowed in a critical section" },
402 { E_NOT_ALLOWED, ERROR_LEVEL_ERROR,
403 "%s not allowed here" },
404 { E_BAD_TAG, ERROR_LEVEL_ERROR,
405 "'%s' is not a %s tag" },
406 { E_ENUM_NON_INTEGER, ERROR_LEVEL_ERROR,
407 "enumeration constant not an integer" },
408 { W_DEPRECATED_PRAGMA, ERROR_LEVEL_WARNING,
409 "pragma %s is deprecated, please see documentation for details" },
410 { E_SIZEOF_INCOMPLETE_TYPE, ERROR_LEVEL_ERROR,
411 "sizeof applied to an incomplete type" },
412 { E_PREVIOUS_DEF, ERROR_LEVEL_ERROR,
413 "previously defined here" },
417 -------------------------------------------------------------------------------
418 SetErrorOut - Set the error output file
420 -------------------------------------------------------------------------------
423 FILE *SetErrorOut(FILE *NewErrorOut)
426 _SDCCERRG.out = NewErrorOut ;
432 setErrorLogLevel (ERROR_LOG_LEVEL level)
434 _SDCCERRG.logLevel = level;
438 -------------------------------------------------------------------------------
439 vwerror - Output a standard eror message with variable number of arguements
441 -------------------------------------------------------------------------------
444 void vwerror (int errNum, va_list marker)
446 if (_SDCCERRG.out == NULL) {
447 _SDCCERRG.out = DEFAULT_ERROR_OUT;
450 if (ErrTab[errNum].errIndex != errNum)
452 fprintf(_SDCCERRG.out,
453 "Internal error: error table entry for %d inconsistent.", errNum);
457 if (ErrTab[errNum].errType >= _SDCCERRG.logLevel) {
458 if ( ErrTab[errNum].errType == ERROR_LEVEL_ERROR )
461 if ( filename && lineno ) {
463 fprintf(_SDCCERRG.out, "%s(%d) : ",filename,lineno);
465 fprintf(_SDCCERRG.out, "%s:%d: ",filename,lineno);
467 fprintf(_SDCCERRG.out, "at %d: ", lineno);
469 fprintf(_SDCCERRG.out, "-:0: ");
472 switch(ErrTab[errNum].errType)
474 case ERROR_LEVEL_ERROR:
475 fprintf(_SDCCERRG.out, "error: ");
477 case ERROR_LEVEL_WARNING:
478 case ERROR_LEVEL_PEDANTIC:
479 fprintf(_SDCCERRG.out, "warning: ");
481 case ERROR_LEVEL_INFO:
482 fprintf(_SDCCERRG.out, "info: ");
488 vfprintf(_SDCCERRG.out, ErrTab[errNum].errText,marker);
489 fprintf(_SDCCERRG.out, "\n");
492 /* Below the logging level, drop. */
496 -------------------------------------------------------------------------------
497 werror - Output a standard eror message with variable number of arguements
499 -------------------------------------------------------------------------------
502 void werror (int errNum, ...)
505 va_start(marker,errNum);
506 vwerror(errNum, marker);
511 -------------------------------------------------------------------------------
512 werrorfl - Output a standard eror message with variable number of arguements.
513 Use a specified filename and line number instead of the default.
515 -------------------------------------------------------------------------------
518 void werrorfl (char *newFilename, int newLineno, int errNum, ...)
520 char *oldFilename = filename;
521 int oldLineno = lineno;
524 filename = newFilename;
527 va_start(marker,errNum);
528 vwerror(errNum, marker);
531 filename = oldFilename;
537 -------------------------------------------------------------------------------
538 fatal - Output a standard eror message with variable number of arguements and
540 -------------------------------------------------------------------------------
542 void fatal (int exitCode, int errNum, ...)
545 va_start(marker,errNum);
546 vwerror(errNum, marker);
553 -------------------------------------------------------------------------------
554 style - Change the output error style to MSVC
555 -------------------------------------------------------------------------------
558 void MSVC_style (int style)
560 _SDCCERRG.style = style;