Problem for linking fortran with c++

Hello

I am currently using a fortran routine from a library ina C++ program, so I can't change its definition, which is:

1
2
3
4
5
extern "C"
{
void FuncFortran_(int*, double*, double*, double*, int*, double*, double*, double*, double*, double* , double**,void(*)(int*,double*,double*),                      
        void(*) (double*, double*, double***, int*, int*, int*), int*, int*);
}


In this fortran routine I need to declare two functions in c++:

1
2
void(*) (int*, double*, double*)
void(*) (double*, double*, double***, int*, int*, int*)


Unfortunately the ones I want to work with are members of a specific class MDA:
1
2
void MDA::funct_(int *n, double* xc, double *fc);
void MDA::monit_(double* fmin, double* fmax, double*** sim, int* n, int* nvert, int* ncall);


When I call my fortran function FuncFortran I got an issue because the functions I use are from (MDA::*)(...) type and not from (void*)(...)

I have tried to transtype (MDA::*)(...) onto (void*)(...) by using static function. Unfortunately it makes FuncFortran return a segmentation fault!!!


Does anybody have a suggestion?

Best
Yes, the functions need to be static. On top of that, you may need to change the calling convention to match that of Fortran. I am not sure, though, as I have never programmed in Fortran before.
Topic archived. No new replies allowed.