Hopefully --vc works now
[fw/sdcc] / support / Util / SDCCerr.c
index 86ae987e0c50dbe3cc945df0c58acd06d7752cd6..9fefee3990f354642ef14c591fa4acb82170e42b 100644 (file)
  */
 
 #include <stdio.h>
+#include <stdlib.h>
 
 #include "SDCCerr.h"
 
-
 #define USE_STDOUT_FOR_ERRORS          0
 
 #if USE_STDOUT_FOR_ERRORS
@@ -32,6 +32,7 @@
 static struct {
     ERROR_LOG_LEVEL logLevel;
     FILE *out;
+       int style; // 1=MSVC
 } _SDCCERRG;
 
 extern char *filename ;
@@ -118,7 +119,7 @@ struct
 { W_TRUNCATION, ERROR_LEVEL_WARNING,
    "high order truncation might occur" },
 { E_CODE_WRITE, ERROR_LEVEL_ERROR,
-   "Attempt to assign value to a constant variable %s" },
+   "Attempt to assign value to a constant variable (%s)" },
 { E_LVALUE_CONST, ERROR_LEVEL_ERROR,
    "Lvalue specifies constant object" },
 { E_ILLEGAL_ADDR, ERROR_LEVEL_ERROR,
@@ -169,7 +170,7 @@ struct
    "Label undefined '%s'" },
 { E_FUNC_VOID, ERROR_LEVEL_ERROR,
    "void function returning value" },
-{ E_VOID_FUNC, ERROR_LEVEL_ERROR,
+{ W_VOID_FUNC, ERROR_LEVEL_WARNING,
    "function '%s' must return value" },
 { W_RETURN_MISMATCH, ERROR_LEVEL_WARNING,
    "function return value mismatch" },
@@ -380,6 +381,10 @@ struct
     "must specify assembler file name with -o in c1 mode" },
 { W_ILLEGAL_OPT_COMBINATION, ERROR_LEVEL_WARNING,
     "illegal combination of options (--c1mode, -E, -S -c)" },
+{ E_DUPLICATE_MEMBER, ERROR_LEVEL_ERROR,
+    "duplicate %s member '%s'" },
+{ E_STACK_VIOLATION, ERROR_LEVEL_ERROR,
+    "'%s' internal stack %s" },
 };
 
 /*
@@ -428,8 +433,11 @@ void vwerror (int errNum, va_list marker)
             fatalError++ ;
   
         if ( filename && lineno ) {
-            fprintf(_SDCCERRG.out, "%s:%d: ",filename,lineno);
-        } else if (lineno) {
+                       if(_SDCCERRG.style)
+                               fprintf(_SDCCERRG.out, "%s(%d) : ",filename,lineno);
+                       else
+                               fprintf(_SDCCERRG.out, "%s:%d: ",filename,lineno);
+         } else if (lineno) {
             fprintf(_SDCCERRG.out, "at %d: ", lineno);
         } else {
             fprintf(_SDCCERRG.out, "-:0: ");
@@ -473,3 +481,30 @@ void werror (int errNum, ... )
     va_end( marker );
 }
 
+
+/*
+-------------------------------------------------------------------------------
+fatal - Output a standard eror message with variable number of arguements and
+        call exit()
+-------------------------------------------------------------------------------
+*/
+void fatal (int exitCode, int errNum, ... )
+{
+    va_list    marker;
+    va_start(marker,errNum);
+    vwerror(errNum, marker);
+    va_end( marker );
+
+    exit(exitCode);
+}
+
+/*
+-------------------------------------------------------------------------------
+style - Change the output error style to MSVC
+-------------------------------------------------------------------------------
+*/
+
+void    MSVC_style (int style)
+{
+       _SDCCERRG.style=style;
+}