I am interested in automatically filtering and interpreting the error messages outputted by gcc and other compilers
For example this regex (which could be improved but you get the idea)
^(.+?):(\d+)(:(\d+))?:\s+(\w+):\s+(.*)$
Would capture the following gcc error
x.cpp:5: error: expected initializer before ‘std’
with
$1= name of source$2= line number$4= column number (not all gcc versions)$5= category (“error” or “warning”)$6= error text
What guarantees are made about the stability and portability of the string format between different versions of gcc? Any guarantees for other compilers?
There’s no guarantee – the Standard will say “the code is ill-formed” and the compiler will emit whatever error it decides.
Also don’t forget that most C++ compiler don’t even produce optimally crafted error messages – there’s nothing to standardize at the moment. For example, if you write:
they will say
no ; before statement2which is right, but not as convenient and useful asno ; after statement1would be. And error messages emitted when compiling templates are so horrible that there’re even stand-alone prettifiers for them.