diff options
author | Torbjörn SVENSSON <torbjorn.svensson@foss.st.com> | 2024-09-26 18:12:46 +0200 |
---|---|---|
committer | Torbjörn SVENSSON <torbjorn.svensson@foss.st.com> | 2024-10-08 09:32:41 +0200 |
commit | 327b4bcfa05021dbc9a0c8269df1d9becc5757af (patch) | |
tree | b8fbb09e24c3e62b6a7d666f4e3eef274802ef7f | |
parent | 0ee028f556401846d27edf0ff67647a1a7a26b6c (diff) | |
download | gcc-327b4bcfa05021dbc9a0c8269df1d9becc5757af.zip gcc-327b4bcfa05021dbc9a0c8269df1d9becc5757af.tar.gz gcc-327b4bcfa05021dbc9a0c8269df1d9becc5757af.tar.bz2 |
diagnostics: Fix compile error for MinGW <7.0
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>
-rw-r--r-- | gcc/diagnostic-color.cc | 8 | ||||
-rw-r--r-- | gcc/pretty-print.cc | 6 |
2 files changed, 12 insertions, 2 deletions
diff --git a/gcc/diagnostic-color.cc b/gcc/diagnostic-color.cc index 8b195d0..2ad708c 100644 --- a/gcc/diagnostic-color.cc +++ b/gcc/diagnostic-color.cc @@ -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 diff --git a/gcc/pretty-print.cc b/gcc/pretty-print.cc index af45210..18c4b2f 100644 --- a/gcc/pretty-print.cc +++ b/gcc/pretty-print.cc @@ -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 (;;) |