* fixed GCC 4.4.0 mingw compilation:
[fw/sdcc] / src / SDCCmain.c
index fd52d5920beb95903d9167125226e85b8c49c391..8b1194ba888fa19275225c1249df88a9d786ab50 100644 (file)
@@ -283,7 +283,7 @@ static const char *_baseValues[] = {
   NULL
 };
 
-static const char *_preCmd = "{cpp} -nostdinc -Wall -std=c99 {cppextraopts} \"{fullsrcfilename}\" \"{cppoutfilename}\"";
+static const char *_preCmd = "{cpp} -nostdinc -Wall {cppstd}{cppextraopts} \"{fullsrcfilename}\" \"{cppoutfilename}\"";
 
 PORT *port;
 
@@ -1988,6 +1988,9 @@ preProcess (char **envp)
       if (options.noOverlay)
         addSet(&preArgvSet, Safe_strdup("-DSDCC_NOOVERLAY"));
 
+      if (options.unsigned_char)
+        addSet(&preArgvSet, Safe_strdup("-DSDCC_CHAR_UNSIGNED"));
+
       /* set the macro for large model  */
       switch (options.model)
         {
@@ -2022,10 +2025,6 @@ preProcess (char **envp)
       if (options.float_rent)
         addSet(&preArgvSet, Safe_strdup("-DSDCC_FLOAT_REENT"));
 
-      /* set macro corresponding to compiler option */
-      if (options.parms_in_bank1)
-        addSet(&preArgvSet, Safe_strdup("-DSDCC_PARMS_IN_BANK1"));
-
       /* add SDCC version number */
       {
         char buf[20];
@@ -2053,7 +2052,7 @@ preProcess (char **envp)
 
       /* standard include path */
       if (!options.nostdinc) {
-        inclList = appendStrSet(includeDirsSet, "-I\"", "\"");
+        inclList = appendStrSet(includeDirsSet, "-isystem \"", "\"");
         mergeSets(&preArgvSet, inclList);
       }
 
@@ -2258,6 +2257,20 @@ initValues (void)
       setMainValue ("linkdstfilename", "{stdlinkdstfilename}");
     }
 
+  /*
+   * Make sure the preprocessor is called with the "-std" option
+   * corresponding to the --std used to start sdcc
+   */
+  if (options.std_c99)
+    {
+      if (!options.std_sdcc)
+        setMainValue ("cppstd", "-std=c99 ");
+    }
+  else
+    {
+      if (!options.std_sdcc)
+        setMainValue ("cppstd", "-std=c89 ");
+    }
 }
 
 static void doPrintSearchDirs(void)