Can't Extend

Pete Shinners pshinners at mediaone.net
Sun May 14 19:36:28 EDT 2000


i'm finding i cannot create my own C extensions for python.
(this time checking with the FAQ) i'm stuck. using Visual C 6
i am consistently getting this error.

ImportError: dynamic module does not define init function (initincr)


as far as i can see, this is incorrect. there is a simple initincr
function. i'm assuming there is some sort of name mangling going on
during the compile/link

anyone have a secret set of visual c flags that gets me a good
clean extension PYD file? here is my sample code (if that helps)

solutions welcome!

-----------------------------------------

#include<Python.h>

static PyObject* incr_func(PyObject* self, PyObject* args);
static PyObject* decr_func(PyObject* self, PyObject* args);

static PyMethodDef IncrMethods[] =
{
    {"incr", incr_func, METH_VARARGS},
    {"decr", decr_func, METH_VARARGS},
    {NULL, NULL}
};

void initincr()
{
    Py_InitModule("incr", IncrMethods);
}


static PyObject* incr_func(PyObject* self, PyObject* args)
{
    int val;

    if (!PyArg_ParseTuple(args, "i", &val))
        return NULL;
    ++val;
    return Py_BuildValue("i", val);
}


static PyObject* decr_func(PyObject* self, PyObject* args)
{
    int val;

    if (!PyArg_ParseTuple(args, "i", &val))
        return NULL;
    --val;
    return Py_BuildValue("i", val);
}








More information about the Python-list mailing list