Is there a way to pretty-print output for templates errors

DCH david@carter-hitchin.clara.co.uk
Fri Mar 23 18:47:00 GMT 2007


STLfilt is pretty handy:

http://www.bdsoft.com/tools/stlfilt.html

I have to say that I found this amazing when I first started using 
the STL, but after a while I can just look at a long message and 
quite quickly get out of it the information I need to fix my code, 
without reaching for something like STLfilt.  I'd only use it now, if 
I had absolutely no clue what was wrong with my code.

Cheers,
David

At 03:44 23/03/2007, David Fang wrote:
> > > Stephen Torri <storri@torri.org> writes:
> > >
> > > > I have a hard time reading the template errors I get from GCC. I was
> > > > wondering if there is a flag for the compiler so that instead 
> of getting
> > > > output like below. I know I failed to present this snapshot in a
> > > > preformatted output. This was deliberate to show how hard is to read
> > > > this on a terminal window.
> > >
> > > Unfortunately there is no such option.
> >
> > BTW, i think the real readability improvement (besides obviously
> > trying to use magic to make them shorter but understandable) would be
> > had from making it visually clear where the word " to non-scalar type"
> > starts.
> >
> > At least for me, half the time I spend trying to interpret the error
> > is going through the 80 lines it spewed trying to find where the
> > template it's complaining about ends and where the error it's actually
> > complaining about begins.
>
> > > Some people find the STLFilt program to be helpful:
> > >     http://www.bdsoft.com/tools/stlfilt.html
>
>Hi all,
>         Years ago, I had similar gripes about reading template errors
>arising from deeply nested templates and long chains of instantiations.
>I put awk to work and wrote the attached makeshift filter
>[balance_indent.awk] that expands templates arguments with tree-like
>indenting and line-breaking.  To use it, pipe the stderr of gcc/g++
>through "awk -f <the-script>".  It's probably far from perfect, but it
>sure took strain off of my eyes in identifying the precise problem.  You
>can customize the matching pattern at the end of the script.
>         To be honest, I haven't used the script in years, and the format
>of the error messages may have changed slightly over the years.  After
>practice, one just sees through the falling glyphs...
>
>Hope it helps some.
>
>Fang
>




More information about the Gcc-help mailing list