]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
diagnostics: Fix compile error for MinGW <7.0
authorTorbjörn SVENSSON <torbjorn.svensson@foss.st.com>
Thu, 26 Sep 2024 16:12:46 +0000 (18:12 +0200)
committerTorbjörn SVENSSON <torbjorn.svensson@foss.st.com>
Tue, 8 Oct 2024 07:32:41 +0000 (09:32 +0200)
The define ENABLE_VIRTUAL_TERMINAL_PROCESSING was introduced in MinGW
7.0

Build failure when building with MinGW 5.0.3:

.../gcc/diagnostic-color.cc:
In function 'bool should_colorize()':
.../gcc/diagnostic-color.cc:317:41:
error: 'ENABLE_VIRTUAL_TERMINAL_PROCESSING' was not declared in this
scope
       mode |= ENABLE_PROCESSED_OUTPUT | ENABLE_VIRTUAL_TERMINAL_PROCESSING;
                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.../gcc/diagnostic-color.cc:317:41:
note: suggested alternative: 'ENABLE_RTL_FLAG_CHECKING'
       mode |= ENABLE_PROCESSED_OUTPUT | ENABLE_VIRTUAL_TERMINAL_PROCESSING;
                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                         ENABLE_RTL_FLAG_CHECKING
.../gcc/diagnostic-color.cc:
In function 'bool auto_enable_urls()':
.../gcc/diagnostic-color.cc:407:50:
error: 'ENABLE_VIRTUAL_TERMINAL_PROCESSING' was not declared in this
scope
   if (GetConsoleMode (handle, &mode) && !(mode & ENABLE_VIRTUAL_TERMINAL_PROCESSING))
                                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.../gcc/diagnostic-color.cc:407:50:
note: suggested alternative: 'ENABLE_RTL_FLAG_CHECKING'
   if (GetConsoleMode (handle, &mode) && !(mode & ENABLE_VIRTUAL_TERMINAL_PROCESSING))
                                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                  ENABLE_RTL_FLAG_CHECKING
Makefile:1195: recipe for target 'diagnostic-color.o' failed
make[1]: *** [diagnostic-color.o] Error 1

gcc/ChangeLog:

* diagnostic-color.cc: Conditionally enable terminal processing
based on define availability.
* pretty-print.cc: Likewise.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
gcc/diagnostic-color.cc
gcc/pretty-print.cc

index 8b195d023eb76b0ea6fbb8e0548d774e4788441b..2ad708c06e6e886c8ce2479e5d6aea360eba48e6 100644 (file)
@@ -311,12 +311,14 @@ should_colorize (void)
   if ((handle != INVALID_HANDLE_VALUE) && (handle != NULL))
     isconsole = GetConsoleMode (handle, &mode);
 
+#ifdef ENABLE_VIRTUAL_TERMINAL_PROCESSING
   if (isconsole)
     {
       /* Try to enable processing of VT100 escape sequences */
       mode |= ENABLE_PROCESSED_OUTPUT | ENABLE_VIRTUAL_TERMINAL_PROCESSING;
       SetConsoleMode (handle, mode);
     }
+#endif
 
   return isconsole;
 #else
@@ -404,7 +406,11 @@ auto_enable_urls ()
   /* If ansi escape sequences aren't supported by the console, then URLs will
      print mangled from mingw_ansi_fputs's console API translation. It wouldn't
      be useful even if this weren't the case.  */
-  if (GetConsoleMode (handle, &mode) && !(mode & ENABLE_VIRTUAL_TERMINAL_PROCESSING))
+  if (GetConsoleMode (handle, &mode)
+#ifdef ENABLE_VIRTUAL_TERMINAL_PROCESSING
+      && !(mode & ENABLE_VIRTUAL_TERMINAL_PROCESSING)
+#endif
+      )
     return false;
 #endif
 
index af452101693b9ac75677630b2fd8b3db80969671..18c4b2fa3509713539a3c3169d538edf623a1746 100644 (file)
@@ -679,7 +679,11 @@ mingw_ansi_fputs (const char *str, FILE *fp)
   /* Don't mess up stdio functions with Windows APIs.  */
   fflush (fp);
 
-  if (GetConsoleMode (h, &mode) && !(mode & ENABLE_VIRTUAL_TERMINAL_PROCESSING))
+  if (GetConsoleMode (h, &mode)
+#ifdef ENABLE_VIRTUAL_TERMINAL_PROCESSING
+      && !(mode & ENABLE_VIRTUAL_TERMINAL_PROCESSING)
+#endif
+      )
     /* If it is a console, and doesn't support ANSI escape codes, translate
        them as needed.  */
     for (;;)