Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs have moved to the Altera Community. Existing Intel Community members can sign in with their current credentials.

passing subroutine names and interface blocks

Brian_Murphy
New Contributor II
5,285 Views

I'm an old dog, and new tricks don't come easy.  I'm trying to setup an interface block in a module for a routine which takes the name of a subroutine as one its arguments, and I'm stumped.  The argument "callback" will be the name of a subroutine which takes one input argument of the same type as the handle variable.  How does one declare the procedure argument?

INTERFACE
        function TF_SetLeaseCallback(handle, callback) bind(c, name = 'TF_SetLeaseCallback') result(retval) 
            import 
            integer(c_int32_t), value :: handle
            WHATGOESHERE :: callback 
            integer(c_long) :: retval
        end function 
        subroutine callback(status)
            integer(c_int32_t) :: status
        end subroutine
END INTERFACE
0 Kudos
23 Replies
Brian_Murphy
New Contributor II
1,030 Views

I will study the code in quote #19 later today.

I have the C header file for the C library.  It is named Turbofloat.h and I have tried to attach it.  Here is the prototype for the C routine which takes a routine name as its second argument.

TURBOFLOAT_API HRESULT TF_CC TF_SetLeaseCallback(uint32_t handle, LeaseCallbackType callback);

Looking elsewhere in the header file for the other definitions.......

define TURBOFLOAT_API __declspec(dllimport)
define TF_CC __cdecl
typedef void(TF_CC * LeaseCallbackType)(uint32_t);

HRESULT seems to be coming from winnt.h as typedef _Return_type_success_(return >= 0) long HRESULT;

0 Kudos
andrew_4619
Honored Contributor III
1,030 Views

typedef int32_t       HRESULT;

0 Kudos
FortranFan
Honored Contributor III
1,030 Views

andrew_4619 wrote:

typedef int32_t       HRESULT;

If that C code (TURBO FLOAT?) is based on Microsoft Windows header(s), then better to follow Microsoft's own documentation:

https://docs.microsoft.com/en-us/windows/win32/winprog/windows-data-types

which defines HRESULT as

typedef LONG HRESULT;

with

typedef long LONG;

 

0 Kudos
Reply