how to precompile headers

Hi!

is it possible to precompile some headers using clang
and then inject it when I compile some code?
(Basically the usual precompiled headers feature)

-Jochen

Yes. IIRC, you can use the -x flag to compile the header

clang -x c-header YourHeader.h -o YourHeader.gch

and the -include flag to include it.

clang -include YourHeader.gch ....

-- Jean-Daniel

Hi!

Yes. IIRC, you can use the -x flag to compile the header

this sounds good, but I'd like to know how it works using the libraries.
Of course I can create the .gch like you told me, but then I want to
use a clang class to load it.

-Jochen

The CompilerInstance and ASTUnit classes are good places to start (both are in libFrontend). You can also take a look at CIndex.cpp, which uses these classes to vend a C interface to Clang for building source code tools.