[v2] diagnostics: Fix compile error for MinGW <7.0
Checks
Context |
Check |
Description |
linaro-tcwg-bot/tcwg_gcc_build--master-arm |
success
|
Build passed
|
linaro-tcwg-bot/tcwg_gcc_build--master-aarch64 |
success
|
Build passed
|
linaro-tcwg-bot/tcwg_gcc_check--master-aarch64 |
success
|
Test passed
|
linaro-tcwg-bot/tcwg_gcc_check--master-arm |
success
|
Test passed
|
Commit Message
Ok for trunk?
Changes since v1:
- Updated the commit message to mention the actual build error.
- Switch to checking the required define rather than the version number of MinGW.
--
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:
* gcc/diagnostic-color.cc: Conditionally enable terminal
processing based on define availability.
* gcc/pretty-print.cc: Likewise.
Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
---
gcc/diagnostic-color.cc | 8 +++++++-
gcc/pretty-print.cc | 6 +++++-
2 files changed, 12 insertions(+), 2 deletions(-)
@@ -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
@@ -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 (;;)