clang: compile c code from char array?

Hi, how do I compile c code from a char array in clang?

Im using code from the interpreter example.
Thanks.

char *cCode; // the char array
// fill array with code goes here...

// Initialize a compiler invocation object from the clang (-cc1) arguments.
  const driver::ArgStringList &CCArgs = Cmd->getArguments();
  llvm::OwningPtr<CompilerInvocation> CI(new CompilerInvocation);
  CompilerInvocation::CreateFromArgs(*CI,
                                     const_cast<const char
**>(CCArgs.data()),
                                     const_cast<const char
**>(CCArgs.data()) +
                                       CCArgs.size(),
                                     Diags);

  // Show the invocation, with -v.
  if (CI->getHeaderSearchOpts().Verbose) {
    llvm::errs() << "clang invocation:\n";
    C->PrintJob(llvm::errs(), C->getJobs(), "\n", true);
    llvm::errs() << "\n";

This thread may help:
http://lists.cs.uiuc.edu/pipermail/cfe-dev/2010-June/009507.html

no, does not help, ive already looked at it.

none none-17 wrote:

I don't know how ccons works, but it may do what you need.

http://code.google.com/p/ccons/

ummm close but no, plus I think it uses an old version of llvm, theres files
thats not in latest version.

Jean-Daniel Dupas-2 wrote: