gccfilter - A filter for gcc diagnostic messages.




gccfilter is a filter to colorize and simplify (or expand) gcc diagnostic messages. gccfilter is particularly aimed at g++ (i.e. regarding C++) messages which can contain lot of template-related errors or warnings difficult to understand.


gccfilter takes as command line arguments, in that order, (1) gccfilter specific options (documented in this page), followed by (2) a gcc command (usally g++) with all it options and source files.


To compile test.cpp

    gccfilter --colorize --remove-template-args g++ -I./include test.cpp

or, short version

    gccfilter -c -a g++ -I./include test.cpp

To use in a Makefile, one can define the variable CXX as

    CXX="gccfilter -c -a g++"


These are gccfilter specific options. These options can be stored in a configuration file. See FILES.


display a short help message.


display the man page.


colorize output.


remove the path before source filenames (the path is replaced by ...).


remove the template arguments between angle brackets.


replace the template arguments with their values displayed in the with clause.


do not display the with clause.


remove the namespaces specified by the --namespaces option. If the --namespaces option is not given, removes all namespaces.

--namespaces|-s namespace-list

list of namepaces to remove with the --remove-namespaces option.


remove all the "instanciated from some-function" lines.

Color options

These options specify the colors for each element of the diagnostic message. The color specification color-spec is a string of color attributes as defined in the Term::ANSIColor(3perl) manpage. To sum up: foreground color attributes are black, red, green, yellow, blue, magenta, cyan, and white. Background color attributes are on_black, on_red, on_green, on_yellow, on_blue, on_magenta, on_cyan, and on_white. Non-color attributes are clear (or reset), bold, dark (or faint), underline (or underscore), blink, reverse, and concealed. Case is not significant. The options are:

--color-filename|-cf color-spec
--color-linenum|-cl color-spec
--color-code|-cc color-spec
--color-withclause|-cw color-spec
--color-error-keyw|-cek color-spec
--color-error-mesg|-cem color-spec
--color-warning-keyw|-cwk color-spec
--color-warning-mesg|-cwm color-spec
--color-note-keyw|-cnk color-spec
--color-note-mesg|-cnm color-spec

Where keyw stands for keyword (error, warning or note, depending on the type of diagnostic) and mesg stands for message (the body of the diagnostic). Example of a (flashy) colors specification:

    colorgcc -c --color-filename 'bold blink green on_red' g++ test.cpp


gccfilter uses the Getopt::ArgvFile(3pm) manpage to allow the storage of commonly used options in configuration files. gccfilter searches for configuration files named .gccfilter in the current working directory and then, if unsuccesfull in the home directory. The format of the file is simple: it contains the options, as if thy were entered in the command line (see the Getopt::ArgvFile(3pm) manpage).


Per directory configuration file.


User's configuration file if the previous file does not exist.


gccfilter exits with the status of the gcc command issued.


gcc diagnostic messages are usually subject to localization. gccfilter does not handle that and invokes gcc in the "C" locale.


gccfilter depends on the following perl modules: the Term::ANSIColor(3perl) manpage, the Getopt::ArgvFile(3pm) manpage, the Getopt::Long(3perl) manpage, the Regexp::Common(3pm) manpage.

The idea of gccfilter commes from colorgcc(1), a tool to colorize gcc output, which seens to be unmaintained for years now. Yet the two programs do not share a single line of code.


Emmanuel Le Trong,


Copyright 2010 by Emmanuel Le Trong.

This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.