bashclangdiagnostics

Change Clang's colored output


Is it possible to change Clang's choice of colors for their colorized diagnostics?

I like my terminal to have a black background, but I just noticed that I was missing Clang's helpful diagnostic messages. I'm aware of the -fno-color-diagnostics compiler option, but I would prefer to have the colors, just different colors.

I'm using a bash shell in OSX.


Solution

  • It looks like the colors are hard-coded near the beginning of this file (include file). You can edit the file and recompile the program, write and submit a feature that accepts color settings at the command line, in an environment variable or from a file, or non-portably try to substitute the colors on the fly.

    Here is an example of the latter:

    clang ... | sed 's/\o33\[30m/\o33[37m/g'
    

    That changes black to white for XTerm escape sequences. Some other sequence would need to be used for other terminal types.