Discussion:
Machine readable build log with gcc warnings
Martin Olsson
2011-03-21 19:27:35 UTC
Permalink
I'm working on webapp that tracks gcc warnings in a large C++ application.
I tried grepping the build log for "warning:" which works well for simple
single line warnings like "unused variable" etc. But g++ sometimes output
multiline warnings like this one:

file.h: In constructor ‘Blah::Blah()’:
file.h:2411: warning: ‘Blah::second’ will be initialized after
file.h:2406: warning: ‘SomeClass* Blah::first’
file.h:2413: warning: when initialized here

...this makes it a bit more complex to parse the build log correctly.
If I don't special-case the multiline warning it will get counted as
three warnings, which is not desirable in my case. Ideally, I don't
want to parse each kind of warning separately because there are quite
a lot of different warnings and new gcc versions might include new
kinds of warnings and warning formatting.

A) Can gcc output a machine readable build log (in XML or whatever)?
B) Is there a list of all warnings GCC can output somewhere?



Martin
Ian Lance Taylor
2011-03-21 20:48:22 UTC
Permalink
Post by Martin Olsson
I'm working on webapp that tracks gcc warnings in a large C++ application.
I tried grepping the build log for "warning:" which works well for simple
single line warnings like "unused variable" etc. But g++ sometimes output
file.h:2411: warning: ‘Blah::second’ will be initialized after
file.h:2406: warning: ‘SomeClass* Blah::first’
file.h:2413: warning: when initialized here
...this makes it a bit more complex to parse the build log correctly.
If I don't special-case the multiline warning it will get counted as
three warnings, which is not desirable in my case. Ideally, I don't
want to parse each kind of warning separately because there are quite
a lot of different warnings and new gcc versions might include new
kinds of warnings and warning formatting.
A) Can gcc output a machine readable build log (in XML or whatever)?
It's a reasonable request, but, no, this is not implemented.
Post by Martin Olsson
B) Is there a list of all warnings GCC can output somewhere?
No. Such a list would be difficult to maintain in practice, unless it
were somehow machine generated from the source code.

Note that the warnings are emitted on multiple lines in order to provide
multiple locations relevant to the warning. However, I think you could
make a good case that this should be using info rather than warning
lines for the second and third line here.

Ian

Loading...