Compilation from memory

Hello,

Is clang able to compile C code from a memory location, instead of from a file ?
I would like to do like so:
http://fdiv.net/2012/08/15/compiling-code-clang-api

but from a memory pointer (so I would write a char array with the includes and the code and give it to clang) in a running application.

Thanks

--š
Jog

Yes. Look at libtooling.

Thanks,

cannot libclang do the same ?
My code is in C and I cannot afford c++ this time…

Yes, this is also possible with libclang. You use the CXUnsavedFile struct when calling clang_parseTranslationUnit.

http://clang.llvm.org/doxygen/structCXUnsavedFile.html