Build one translation-unit out of multiple source-files

As the subject says: Is it possible to build one translation-unit out of multiple source-files?
I copied the source to create a compilerinstance from
https://github.com/gwaredd/reflector/blob/master/src/Reflector.cpp
For every inputfile, the FileManager, SourceManager, Preprocessor, ASTContext and
Sema will be recreated. Thus, every sourcefile ends up in it’s own TranslationUnit.
I am aware of the possibility to simply include all given sourcefiles inside a temporary
sourcefile - it works, but it feels ‘hacky’.
Any suggestions?

  • Hendrik

I don’t think there’s a better way to do it within the Clang parser. You might be able to link the bitcode files together using the LLVM linker (llvm-ld).

  • Doug

Ok, thank you.

2011/3/21 Douglas Gregor <dgregor@apple.com>