On Sun, Mar 31, 2013 at 1:01 PM, Manuel López-Ibáñez <lopeziba...@gmail.com> wrote: > The following patch implements an option that allows printing the > diagnostics markers ("error:", "warning:", "note:") in different > colors (red, magenta, and green, respectively). > > I followed the implementation of GNU grep but we cannot directly use > their code, since they only care about printing to stdout, while we > need to create strings on the fly. > > This patch only supports POSIX terminals, but grep has code for > Windows, so I can implement that if wished. > > Grep also supports configuring the colors via an environment variable, > so I can extend the patch in that way if wished. > > This patch only allows two options enable/disable colors (and defaults > to disabled), but grep has auto/never/always, and I can easily extend > the patch in that way. > > The patch is very simple (only colors the markers, and that is it). > Nonetheless, I find this a significant improvement when reading the > output of GCC in a terminal. I tried with several backgrounds (all the > ones available in Yakuake/Kterminal), and the colors are readable. > > The ideal approach would be that GCC produced diagnostics in some > structured, machine-readable form, and that structured form be > translated into GNU style terminal output with/without colors (or > HTML, or parsed by IDEs, etc). However, that would require > significantly more effort that I (or anyone else, as far as I know) > can dedicate to this. But, in any case, I believe such approach would > probably use the same functions proposed here to color text, so the > current patch is still useful if someone decided to try. > > So the question is: Is there any chance this patch (once tidied, and > whatever desired improvements implemented) is accepted in GCC? > > What are the desired improvements (customization, auto setting, > Windows support)?
A couple of things. I think should be able to control the coloring by a real environment variable like LS_COLOR allows. fdiagnostics-show-color should be controllable by an env variable so you don't have to pass an argument to gcc all the time. The win32 implementation should be the same as the POSIX implementation or rather at least the cygwin version should be the same. Thanks, Andrew