Compile MemoryBuffer

Dear Developers,

First, thank you very much for your work.
I believe clang is a great tool and I can't wait to use it in my programs.

I'm totally new to clang, but I'm willing to learn.
.... With your help :slight_smile:

I believe this has been asked already many times...

So, here's my question:
I would like to use clang in my application for scripting and definition jit-compilation of functions to be used as callbacks in the c++ application.
This is the "big" (and unclear I know) frame.
But let's go step by step...

My question is how can I jit-compile and evaluate c / c++ code packed into a string like:
"int foo(int a, int b) { int r; r=a+b; return r;}"
and then in a subsequent step evaluate:
"foo(2,3)"

I think I understood this is done using MemoryBuffers.
But I can't get it to work.
I'm currently basing my experiments on the clang-interpreter example code.

I know there are some code snippetts around the web about this issue but I can't get them all together working.
It would be extremely helpful if someone could post some "working" code to do this so that I can then use, look, experiment and understand better what's going on.
That would be great!

Thank you very much for you help in advance.

Bests,

David

Take a look at ccons:

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

-Alexei

Thank you,

I had already found this.
But this code doesn't work with the actual version of llvm / clang.

Any other ideas?

Bests,

David

I've just fixed the build problem with TOT clang. Try now.

-Alexei

Dear Alexei,

Works!!
Wonderful.
Thank you!

Bests,

David