1
1- project -> properties
2- All Configurations -> x64
3- General
Target Extension: .pyd
4- VC++ Directories
Include Directories: D:\Python27\include
Library Directories: D:\Python27\libs
2
1- include.h
#ifdef _DEBUG
#define _DEBUG_WAS_DEFINED 1
#undef _DEBUG
#endif // _DEBUG
#include <Python.h>
#ifdef _DEBUG_WAS_DEFINED
#define _DEBUG 1
#endif // _DEBUG_WAS_DEFINED
2- main.cpp
#include "include.h"
PyObject* some_function(PyObject* self, PyObject* args)
{
int i;
if (!PyArg_ParseTuple(args, "i", &i)) {
goto error;
}
return PyInt_FromLong(i + 1);
error:
return 0;
}
PyMethodDef SpamMethods[] =
{
{"add_one", (PyCFunction)some_function, METH_VARARGS, 0},
{0, 0, 0, 0}
};
PyMODINIT_FUNC
initspam(void)
{
PyObject *m;
m = Py_InitModule("spam", SpamMethods);
if (m == NULL)
return;
}