Is there a way to re-direct Cling’s stdout/stderr to a std::string?
I am using metaprocesor’s process function. How I can get the error from the execution of the last statement into a string.
int ret_val = metaProcessor->process(input_line, compRes, &value, disableValuePrinting);
if (compRes != cling::Interpreter::kSuccess) {
string result = "Statement is not correct."; //How I get the excat error message?
}
clang::TextDiagnosticBuffer might do what you need. You can set the diagnostic consumer with the clang::CompilerInstance as returned by cling:: Interpreter