Reputation: 1071
Given c/cpp/.h files, I want to compile them and find the compilation errors (and warnings).
From the compilation error, I want to produce a structure or table like,
{
level: (ERROR/WARNING)
fileName: 'hello.cc'
lineNumber: 24
char: 5 (if available, or can be skipped)
message: 'The description of the error'
}
I looked at some error messages. For many error messages from gcc, I am looked at, all the error lines start with 'filename: In function main
' or 'filename:lineNumber:column
'
And all the multi line error messages are indented by some whitespace
Is it safe to assume, lines starting with non-whitespace characters are the beginning of error lines?
Note: I had never written c++ programs in the last 10 years, I am building C/C++ support for Codiva.io online compiler (that only supports java at present). I feel, instead of giving a console output, parsing and showing at each line would be a good user experience and saves a ton of time for students. Will parsing error messages from clang compiler be easier?
Upvotes: 1
Views: 2227
Reputation: 2999
With the upcoming gcc 9.0, there is an option to output JSON: -fdiagnostics-format=json
Upvotes: 4