- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Export of generic functions
I have a module (se below) and I want to export the geniric function/ Interface "GetCurrentTime": How can I do that?
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! MY DLL ENGINE !!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Module MEngine
implicit none
save
PRIVATE
....
Interface GetCurrentTime
module procedure dblGetCurrentTime
module procedure sglGetCurrentTime
end interface
....
....
PUBLIC::
GetCurrentTime
Contains:
! GetCurrentTime
subroutine dblGetCurrentTime (dout)
real*8 ,intent(out):: dout
dout = uznow
return
end subroutine dblGetCurrentTime
subroutine sglGetCurrentTime (fout)
real*4 ,intent(out):: fout
fout = uznow
return
end subroutine sglGetCurrentTime
....
End Module MEngine
I have a module (se below) and I want to export the geniric function/ Interface "GetCurrentTime": How can I do that?
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! MY DLL ENGINE !!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Module MEngine
implicit none
save
PRIVATE
....
Interface GetCurrentTime
module procedure dblGetCurrentTime
module procedure sglGetCurrentTime
end interface
....
....
PUBLIC::
GetCurrentTime
Contains:
! GetCurrentTime
subroutine dblGetCurrentTime (dout)
real*8 ,intent(out):: dout
dout = uznow
return
end subroutine dblGetCurrentTime
subroutine sglGetCurrentTime (fout)
real*4 ,intent(out):: fout
fout = uznow
return
end subroutine sglGetCurrentTime
....
End Module MEngine
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What do you mean "export"? Dllexport? No, you can't "export" it in the usual sense -- that info is available only during compile-time, and compiler actually always produces code which calls one of specific function when it resolves which one. I didn't look at .obj files of routines which call generic functions, but I'd bet you'll find only the specific names imported. In other words, GetCurrentTime ends up only in .mod files, but not in .obj files.
What you can do is to add the MEngine.mod to your .exe project -- I think that will work (provided that the .exe is in Fortran).
Jugoslav
What you can do is to add the MEngine.mod to your .exe project -- I think that will work (provided that the .exe is in Fortran).
Jugoslav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
By export I mean dllexport and my .exe project is not a fortran program, but a C# program.
Could I instead dllexport each module procedure ??
Could I instead dllexport each module procedure ??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, you can -- I recommend using ALIAS attribute (or a .def file) as well, because otherwise you'll get ugly name mapping, like _MENGINE_mp_SGLGETCURRENTTIME:
subroutine sglGetCurrentTime (fout)
!dec$attributes dllexport, decorate, alias: "sglGetCurrentTime":: sglGetCurrentTime
will export "_sglGetCurrentTime@4" and you will call it from C# as "sglGetCurrentTime".
Jugoslav
subroutine sglGetCurrentTime (fout)
!dec$attributes dllexport, decorate, alias: "sglGetCurrentTime":: sglGetCurrentTime
will export "_sglGetCurrentTime@4" and you will call it from C# as "sglGetCurrentTime".
Jugoslav
![](/skins/images/71A9511A625CE5D5D45FB59952A4AA71/responsive_peak/images/icon_anonymous_message.png)
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page