[C++-sig] void* cast to a specific type based on string name

Roman Yakovenko roman.yakovenko at gmail.com
Fri Oct 3 21:18:54 CEST 2008

On Fri, Oct 3, 2008 at 10:06 PM, Renato Araujo <renatox at gmail.com> wrote:
> Hi thanks for your help, but I already tried this:
> This is the code:
> void call_Pyfunction(int argc, char **types, void **args, PyObject *callbak)
> {
>     PyObject *pyargs = PyTuple_New(argc);
>     for (int i=0; i < argc; i++)
>     {
>        PyObject *o = boost::python::object(args[i]).ptr();
>        PyTuple_SetItem(pyargs, i, boost::python::incref(o));
>     }
>     PyObject_Call(callback, pyargs, NULL);
> }
> I got this error during the object creation:
> terminate called after throwing an instance of
> 'boost::python::error_already_set'

I would find out what cause the error.

It seems that you are trying to implement functionality that already
exists in trunk.
Search this mailing list, there are few posts that discuss how to call
any python function.

Roman Yakovenko
C++ Python language binding

More information about the Cplusplus-sig mailing list