Use PyInt_AsLong
to convert the return value to C long.
...
if (PyCallable_Check(pFunc)) {
PyObject *res = PyObject_CallObject(pFunc, NULL);
if (res != NULL) {
long n = PyInt_AsLong(res); // <---------
cout << n << endl;
} else {
PyErr_Print();
}
...