- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I use the procedure described in sample LoadExp1 to load subroutines from a DLL. This method fails when trying to load functions from a DLL.
The compiler starts complaining about the return value of the function not having a type, and that it must have an explicit type (although an interface is available).
The problem is related to the fact that there also exists a Cray-pointer which is intended to hold the function address.
Is this is caused by some kind of mix-up between function address and function return value?
I know that the pointee of the Cray-pointer cannot be a function result, but it is not at the pointer declaration where the compiler starts complaining, but at the point where I try to get the return value of the function.
How can I work around this problem?
Thanks,
Walter Kramer
I use the procedure described in sample LoadExp1 to load subroutines from a DLL. This method fails when trying to load functions from a DLL.
The compiler starts complaining about the return value of the function not having a type, and that it must have an explicit type (although an interface is available).
The problem is related to the fact that there also exists a Cray-pointer which is intended to hold the function address.
Is this is caused by some kind of mix-up between function address and function return value?
I know that the pointee of the Cray-pointer cannot be a function result, but it is not at the pointer declaration where the compiler starts complaining, but at the point where I try to get the return value of the function.
How can I work around this problem?
Thanks,
Walter Kramer
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Haven't had any problem of this sort, do you have a small example?
James
James
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The cause of the problem was something completely different then I expected. It had to do with the placement of a use statement:
The code as shown above generates the error.
If I move the
I hadn't expected this, but it solves my problem.
There is a relation with the pointer assignment though, because the following code will compile without any complaint:
Thanks,
Walter Kramer
Module mod_A
Interface
real(4) function Func_A(a)
real(4), intent(in) :: a
end function Func_A
End Interface
End Module mod_A
module mod_B
use mod_A
contains
real(4) function Func_B(lib,a)
use kernel32
! use mod_A
implicit none
character(*), intent(in) :: Lib
real(4), intent(in) :: a
pointer(q,Func_A)
integer(4) :: p
p=LoadLibrary(trim(Lib)//char(0))
q = getprocaddress(p, "Func_A"C)
Func_B=Func_A(a)
end function Func_B
end module mod_BThe code as shown above generates the error.
If I move the
use mod_Astatement from module level to function level everything functions OK.
I hadn't expected this, but it solves my problem.
There is a relation with the pointer assignment though, because the following code will compile without any complaint:
Module mod_A
Interface
real(4) function Func_A(a)
real(4), intent(in) :: a
end function Func_A
End Interface
End Module mod_A
module mod_B
use mod_A
contains
real(4) function Func_B(a)
implicit none
real(4), intent(in) :: a
Func_B=Func_A(a)
end function Func_B
end module mod_BThanks,
Walter Kramer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I think the error message for your original code is a bug. We'll look into it.
Steve
Steve
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