Ok for trunk? --
The define ENABLE_VIRTUAL_TERMINAL_PROCESSING was introduced in MinGW 7.0 gcc/ChangeLog: * gcc/diagnostic-color.cc: Conditionally enable terminal processing based on available MinGW version. * gcc/pretty-print.cc: Likewise. Signed-off-by: Torbjörn SVENSSON <torbjorn.svens...@foss.st.com> --- gcc/diagnostic-color.cc | 8 +++++++- 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 8b195d023eb..700f315e57e 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); +#if defined(__MINGW64_VERSION_MAJOR) && __MINGW64_VERSION_MAJOR >= 7 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) +#if defined(__MINGW64_VERSION_MAJOR) && __MINGW64_VERSION_MAJOR >= 7 + && !(mode & ENABLE_VIRTUAL_TERMINAL_PROCESSING) +#endif + ) return false; #endif diff --git a/gcc/pretty-print.cc b/gcc/pretty-print.cc index 68c145e2d53..a99dd312260 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) +#if defined(__MINGW64_VERSION_MAJOR) && __MINGW64_VERSION_MAJOR >= 7 + && !(mode & ENABLE_VIRTUAL_TERMINAL_PROCESSING) +#endif + ) /* If it is a console, and doesn't support ANSI escape codes, translate them as needed. */ for (;;) -- 2.25.1