[cfe-dev] Default Headers with CompilerInstance
klimek at google.com
Thu Nov 8 10:22:40 PST 2012
See here for what's needed to build a tool on top of clang:
(the solution is to use the Driver, which handles finding of builtin and
Alternatively, you can just use the tooling library :) (see
On Wed, Nov 7, 2012 at 11:42 PM, Antoine Trouve <trouve at isit.or.jp> wrote:
> Hello everybody
> 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.
> Best regards,
> - Antoine
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cfe-dev