Boost logo

Boost Users :

From: Robert Dailey (rcdailey_at_[hidden])
Date: 2008-02-18 18:16:38


Hi,

Below is my source code. What I'm trying to do is expose a C++ function to
the embedded interpreter so I may call it from scripts executed by that
embedded interpreter. Right now it just crashes with what seems to be an
access violation against NULL:

SOURCE:
---------------------------------------------------------------------------
static void DoFoo()
{
    int breakhere = 0;
}

using namespace boost;

BOOST_PYTHON_MODULE(pythontest)
{
    python::def( "DoFoo", DoFoo );
}

void SetupPython()
{
    if( PyImport_AppendInittab( "pythontest", NULL ) != -1 )
    {
        int breakhere = 0;
    }
    else
    {
        int breakhere = 0;
    }

    python::object pytest = python::exec_file( "pythontest.py" );
}

void BeginPythonTest()
{
    Py_Initialize();

    SetupPython();
}

The pythontest.py file does nothing more than call *DoFoo()*.

I've been looking at the *boost\libs\python\example\quickstart\embedding.cpp
*, however it isn't very helpful and hard to read. In addition it calls a
function named "initembedded_hello" which is nowhere to be found... This
won't even compile?

Any help is greatly appreciated!



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net