I am trying to pass the address of a C++ function into a Fortran
routine to enable the Fortran routine to call this C++ function. I
have to do it this way as our build process does not allow circular
dependencies of DLL's.
Does anyone know how to do this, I have tried everything in my book.
I have a C++ function GetP:
DllExport void GetP()
{
...code...
return;
}
I am trying to pass the address of this function into a Fortran
routine called BIND_FTN. The call is made from another area of the
C++ code as follows:
void (GetP)();
DllImport void __stdcall BIND_FTN(int* GetP);
void Initialize()
{
...code...
BIND_FTN(GetP); // inform Fortran of address of callback
function
return;
}
The C++ will not compile, I get:
error C2664: 'BIND_FTN' : cannot convert parameter 1 from 'void
(__cdecl *)(void)' to 'int *'
Can anyone see the problem here?
Here is the Fortran code for BIND_FTN:
subroutine BIND_FTN_EXTERNALS[DLLEXPORT](ext)
external ext
interface
subroutine cb_GetP()
!DEC$ ATTRIBUTES STDCALL :: cb_GetP
end subroutine cb_GetP
end interface
pointer (p_GetP, cb_GetP)
p_GetP = loc(ext)
call cb_GetP ! call the C++ function from Fortran
return
end
(I haven't got to the Fortran yet - there may be syntax errors in
there)
Adrian