Image

modules on windows

Hello,

I am trying to make my very first python module. I am using an example i found in a book and i am building with Visual Studio 2005. For some reason, everytime i try and import this it says i get the following error.

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

I am guessing i am missing something very stupid but it is not obvious to me. I have placed my code of dialog.cpp behind a cut.


#include "stdafx.h"
#include "python.h"



static PyObject *simple_add(PyObject *pSelf, PyObject *pArgs)
{
PyObject *pX, *pY;

if (!PyArg_ParseTuple(pArgs, "OO", &pX, &pY))
return NULL;
return PyNumber_Add(pX, pY);
}



static char count_doc[] = "Returns the number of arguments passed in";

static PyObject *simple_count(PyObject *pSelf, PyObject *pArgs)
{
long count = PyTuple_Size(pArgs);
return PyInt_FromLong(count);
}

static PyMethodDef simple_methods[] =
{
{"add", simple_add, METH_VARARGS, NULL},`
{"count", simple_count, METH_VARARGS, count_doc},
{NULL, NULL}
};

DL_EXPORT(void) extern "C" initdialog()
{
(void)Py_InitModule3("dialog", simple_methods, simple_doc);
}

BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{





return TRUE;
}