clang-interpreter example and in-memory buffer

Hi all,
  I'm new to libclang/etc; I'm trying to do something very similar to what the "clang-interpreter" example is doing, except I'm playing with generating the .cpp file dynamically.

  I could write it out to a temp file, but that means dealing with temp files... I already have the content I want in a string in memory. I'm just wondering if there's a reasonably-simple way to pass the file data in directly rather than actually writing it to a file? Any pointers?

Thanks,
Adam

+1
I was also trying to figure this out, during the week, for some source to source transformations.

Hi all,
  I'm new to libclang/etc; I'm trying to do something very similar to what the "clang-interpreter" example is doing, except I'm playing with generating the .cpp file dynamically.

  I could write it out to a temp file, but that means dealing with temp files... I already have the content I want in a string in memory. I'm just wondering if there's a reasonably-simple way to pass the file data in directly rather than actually writing it to a file? Any pointers?

clang_parseTranslationUnit from libclang provides the option to pass source files via memory buffers ("unsaved_files" parameter).
You can "follow" its code path to see how this can be done programmatically.