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'
}
- In Java, there is a Java Compiler API. Is there a similar API for C++?
- If the only option is to parse the output of gcc or g++, how to parse the error message, so that I can generate an array of the structure as defined above?
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?
SO.