[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Passing functions from C++ DLD to Fortran and vise versa
From: |
Thomas Treichl |
Subject: |
Passing functions from C++ DLD to Fortran and vise versa |
Date: |
Wed, 06 Jun 2007 23:58:40 +0200 |
User-agent: |
Thunderbird 1.5.0.12 (Macintosh/20070509) |
Hi,
I've a (hopefully simple) problem that I can't figure out. I'm trying to pass a
function pointer from C++ to a Fortran routine and vise versa. But at the step
of compilation I fail and don't know what to do at the moment:
$ mkoctfile ex4a.f ex4a.cc
ex4a.cc: In function 'octave_value_list Fex4a(const octave_value_list&, int)':
ex4a.cc:16: error: invalid conversion from 'void (*)(int*, double*)' to 'void*'
ex4a.cc:16: error: initializing argument 3 of 'void ffuncall_(int*, double*,
void*)'
Can somebody help please? The files I'm using are attached.
Thomas
C Example 4a, function ffuncall ()
subroutine ffuncall (vn, vd, vp)
integer vn
double precision vd
external vp
C
print *, ' Example 4a: Fortran side: numbers are', vn, vd
C
call vp (vn, vd)
return
end
/* Example 4a, Interfacing Fortran function ffuncall () */
#include <octave/oct.h>
#include <iostream>
extern "C" void F77_FUNC (ffuncall, FFUNCALL) (int *vn, double *vd, void *vp);
extern "C" void F77_FUNC (ffun, FFUN) (int *vint, double *vdbl) {
printf (" Example 4a: C side: Fortran called C function ffon with numbers
%d %f\n",
*vint, *vdbl);
}
DEFUN_DLD (ex4a, args, nargout, "ex4a") {
int vnum = 11;
double vdob = 22.22;
F77_FUNC (ffuncall, FFUNCALL) (&vnum, &vdob, F77_FUNC (ffun, FFUN));
std::cout << " Example 4a: C++ side: Fortran function finished, back in C++
function\n";
}
- Passing functions from C++ DLD to Fortran and vise versa,
Thomas Treichl <=