You aren't going to be able to simply cast a Python function to C like that.
Instead pass the PyObject function pointer, call the function, and convert to C double. This code will return -1
on failure.
static double cFx(PyObject *fx, double x){
PyObject *pyresult = PyObject_CallFunction(fx, "d", x);
if (pyresult == NULL) return -1;
double cppresult = PyFloat_AsDouble(pyresult);
Py_DECREF(pyresult);
if (PyErr_Occurred()) return -1;
return cppresult;
}
Important part of this is to decrement the reference count to the return value of PyObject_CallFunction
since you aren't passing it off to the Python interpreter to deal with.