g++ output formatter

Anyone who’s done much work with metaprogramming or heavy STL usage in C++ will be familiar with this:

g++ ugly output

While Clang’s output is often slightly less ugly than GCC, it’s still fairly cryptic.

To resolve this, I wrote a perl script which re-formats GCC output. Simply pipe your GCC output into the script, then optionally into less -R to get nicer output:

c++ pretty output

There are two files required, the actual formatter c++-color and a helper cxx-type-formatter specifically for data-types:

Put c++-color in somewhere in your $PATH and mark it executable, alter the require line to point to where you saved cxx-type-formatter then to use the formatter, pipe gcc/g++ into it:

# Example

$ g++ -std=c++14 -Wall -g *.cpp -o my-app    2>&1 | c++-color | less -R

It is important to pipe gcc’s STDERR stream into STDOUT with the 2>&1, otherwise the formatter can’t operate on it.

Happy debugging!