views:

217

answers:

3

In order to pass some code to an application created with C++ I have used a C++ open source code which acted as a TCL interpreter. So I could create a file, in there put some XML data and in some tags some TCL code. Finally it is possible to read the file configure some structure and execute the TCL script snippets from the XML file in appropriate places. In order to not use C++ and TCL simultaneously I ask the following:

Is there an open-source C++ code that can execute a C++ code without compiling? In other words is there a C++ interpreter.

+6  A: 

I must admit I didn't expect there to be one, but a search has revealed the following:

Ch

However:

Ch (pronounced /ˌsiːˈeɪtʃ/) is a cross-platform C and C++ interpreter. It is provided by SoftIntegration, Inc for C/C++ users. Ch is useful for scripting, shell programming, 2D/3D plotting, numerical computing, and can be embedded in other applications to add scripting capability. Ch can be used for both server-side and client-side web development. It runs under Windows, Linux, Mac OS X and some versions of Unix. Ch supports C90 and major C99 features, but it doesn't support full C++ features.

Source

So check it covers the features you need.

ChrisF
I've used it for years as a commandline C interpreter, just as a programmers calculator. It also has a bunch of unix tools and a nice bash shell.Haven't used it in a program
Martin Beckett
+5  A: 

Yes. Check this out: http://root.cern.ch/drupal/content/cint (it is free software, too).

Apart from that: you can certainly find a better solution than embedding a C++ interpreter, especially with far more light-weight, easily embedabble languages like Lua, Python, etc.

Greg S
+9  A: 

CINT

What is CINT?

CINT is an interpreter for C and C++ code. It is useful e.g. for situations where rapid development is more important than execution time. Using an interpreter the compile and link cycle is dramatically reduced facilitating rapid development. CINT makes C/C++ programming enjoyable even for part-time programmers.

CINT is written in C++ itself, with slightly less than 400,000 lines of code. It is used in production by several companies in the banking, integrated devices, and even gaming environment, and of course by ROOT, making it the default interpreter for a large number of high energy physicists all over the world.

SigTerm