[cfe-dev] clang errors vs clang_getDiagnostics

Anders Bakken agbakken at gmail.com
Mon Jan 21 23:25:32 PST 2013


Hi

I have a problem with using diagnostics with the C API.

I do this on the command line:

main.cpp:

void foobar();

int main() {
  foobaz();
}

clang main.cpp

I get this:

main.cpp:4:3: error: use of undeclared identifier 'foobaz'; did you
mean 'foobar'?
  foobaz();
  ^~~~~~
  foobar
main.cpp:1:6: note: 'foobar' declared here
void foobar();
     ^
1 error generated.

If I do the same thing with clang_parseTranslationUnit and then
clang_getDiagnostic I don't seem to get this suggestion. I just get:

error: use of undeclared identifier 'foobaz' [2, Semantic Issue]

Do I need to pass a switch that is on by default for clang itself?

regards

Anders



More information about the cfe-dev mailing list