[Matrix-SIG] Compile problem
Jeff Collins
collins@seal.aero.org
Fri, 9 Jul 1999 15:38:50 -0700
I'm trying to run the function "test" in the following shared extension
module. Under irix6.5 (compiled with g++ in egcs-1.1.2), a
segmentation fault occurs as it executes the cout statement. It works
fine with the same compiler on Solaris-5.6. Any ideas what might be
going wrong? In both cases, Python-1.5.2 was compiled with gcc
(egcs-1.1.2) and g++ was used for the shared object linking.
This is the simplest form of the problem I'm having. It first
appeared in an attempt to create python wrappers for a custom c++
wrapping of fftw; calls to those functions failed in the same way.
Thanks,
Jeff
--------------------------------------------------------------------------------
#include "Python.h"
#include <complex.h>
#include <iostream.h>
static
PyObject *jnk_test (PyObject *self, PyObject *args)
{
complex<double> *a;
if (!PyArg_ParseTuple(args, ""))
return NULL;
printf("before a\n");
a = new complex<double>(0,1);
printf("a = %g %g\n", real(*a), imag(*a));
delete a;
printf("before cout\n");
cout << "some stuff" << endl;
Py_INCREF(Py_None);
return Py_None;
}
static PyMethodDef jnk_methods[] = {
{"test", (PyCFunction) jnk_test, 1},
{NULL, NULL}
};
#ifdef __cplusplus
extern "C" {
#endif
void
initjnk()
{
PyObject *m;
m = Py_InitModule("jnk", jnk_methods);
if (PyErr_Occurred())
Py_FatalError("Can't initialize module jnk");
}
#ifdef __cplusplus
}
#endif