How to highlight error generated with the ninja build system?

Viewed 1951

How would I manage to highlight errors and warnings generated by ninja when I compile cpp? When I get errors, I only see white text, and it would improve readability if I could highlight errors and warnings.

2 Answers

You do not see errors because the compiler notice it is not outputint its message to a terminal, so it defaults to no color. With GCC you can force colored output with the -fdiagnostics-color=always command line option.

In case there is still someone out there struggling with this (like how I was not too long ago), here's what worked for me:

As this link and Oliv highlighted out, one needs to force Ninja to use colors (via -fdiagnostics-color on GCC>=4.9 or -fcolor-diagnostics for Clang)

This will force Ninja to format the specific output elements with the format defined in the GCC_COLORS environment variable.

FYI: If this variable is an empty string, then there is no coloring at all.

On how to configure this, see https://gcc.gnu.org/onlinedocs/gcc-5.1.0/gcc/Language-Independent-Options.html, where the default configuration is also included as an example.

Related