[cfe-dev] Default Headers with CompilerInstance
trouve at isit.or.jp
Wed Nov 7 23:42:31 PST 2012
I am now using clang API in order to alter some C sources using my custom ASTVisitor, and I am struggling to make my CompilerInstance object to know about the path of default system headers.
I have a protoype that uses the object CompilerInstance to initialize all the important stuffs (DiagnosticsEngine, Preprocessor ...) and calls "clang::ParseAST" at the end to use my own visitor.
This prototype works well for simple file that do not use any system headers (e.g. "stdlib.h"), but when I want to use these, I get errors like:
$ tsc.c:34:10: fatal error: 'stdlib.h' file not found
$ #include <stdlib.h>
If I set "Verbose = 1" to the HeaderSearchOptions of my CompilerInstance object, I can see that indeed, my search list is empty:
$ #include "..." search starts here:
$ End of search list.
I tried to add the system headers manually using "HeaderSearchOptions.Add" but (1) this is not portable and (2) anyway I can't make that work either.
Could you please explain me more in details how Clang does to find the default system headers ?
I attach the source file of my simple prototype.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 14270 bytes
Desc: not available
More information about the cfe-dev