Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #6159

Re: Compiling and executing during runtime in C++?

From Nobody <nobody@nowhere.com>
Subject Re: Compiling and executing during runtime in C++?
Date 2011-06-03 23:54 +0100
Message-Id <pan.2011.06.03.22.54.41.313000@nowhere.com>
Newsgroups comp.lang.c++
References <c98b9bc9-74af-40a3-885c-d1a2955206cd@v10g2000yqn.googlegroups.com>
Organization Zen Internet

Show all headers | View raw


On Fri, 03 Jun 2011 04:22:15 -0700, Kasper Middelboe Petersen wrote:

> I'm porting a python library to C++.
> Part of this takes a string (in this case the variable action could be
> something like a function call or simply "i = 25") and both compiles
> and runs it within the context it is running as shown here:

> Is this possible to do in C++? And if so, please point me in the right
> direction :)

Is the "code" supposed to be in C++ or Python?

If it's in Python, then you need to link against the Python library and
use its C API. See the "Extending and Embedding" section in the Python
documentation. And direct further questions to a Python forum.

If it's in C++ ... well C++ really isn't that sort of language. It isn't
particularly meaningful to evaluate fragments of code in the sense of a
high-level language's eval() function.

If you just need some form of run-time extensibility which includes
expressions, you might want to consider Lua, as it's specifically
oriented towards embedding in larger programs.

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Compiling and executing during runtime in C++? Kasper Middelboe Petersen <fantyfant@gmail.com> - 2011-06-03 04:22 -0700
  Re: Compiling and executing during runtime in C++? Michael Doubez <michael.doubez@free.fr> - 2011-06-03 05:41 -0700
  Re: Compiling and executing during runtime in C++? Nobody <nobody@nowhere.com> - 2011-06-03 23:54 +0100
    Re: Compiling and executing during runtime in C++? Kasper Middelboe Petersen <fantyfant@gmail.com> - 2011-06-04 05:57 -0700

csiph-web