2016 Update

This commit is contained in:
Tina Müller 2016-12-05 22:15:40 +01:00
parent 948b86eafa
commit dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions

View file

@ -0,0 +1,6 @@
function ffun(x, y)
implicit none
!DEC$ ATTRIBUTES DLLEXPORT, STDCALL, REFERENCE :: FFUN
double precision :: x, y, ffun
ffun = x + y * y
end function

View file

@ -0,0 +1,30 @@
program dynload
use kernel32
use iso_c_binding
implicit none
abstract interface
function ffun_int(x, y)
!DEC$ ATTRIBUTES STDCALL, REFERENCE :: ffun_int
double precision :: ffun_int, x, y
end function
end interface
procedure(ffun_int), pointer :: ffun_ptr
integer(c_intptr_t) :: ptr
integer(handle) :: h
double precision :: x, y
h = LoadLibrary("dllfun.dll" // c_null_char)
if (h == 0) error stop "Error: LoadLibrary"
ptr = GetProcAddress(h, "ffun" // c_null_char)
if (ptr == 0) error stop "Error: GetProcAddress"
call c_f_procpointer(transfer(ptr, c_null_funptr), ffun_ptr)
read *, x, y
print *, ffun_ptr(x, y)
if (FreeLibrary(h) == 0) error stop "Error: FreeLibrary"
end program

View file

@ -0,0 +1,6 @@
function ffun(x, y)
implicit none
!GCC$ ATTRIBUTES DLLEXPORT, STDCALL :: FFUN
double precision :: x, y, ffun
ffun = x + y * y
end function

View file

@ -0,0 +1,30 @@
program dynload
use kernel32
use iso_c_binding
implicit none
abstract interface
function ffun_int(x, y)
!GCC$ ATTRIBUTES DLLEXPORT, STDCALL :: FFUN
double precision :: ffun_int, x, y
end function
end interface
procedure(ffun_int), pointer :: ffun_ptr
integer(c_intptr_t) :: ptr
integer(handle) :: h
double precision :: x, y
h = LoadLibrary("dllfun.dll" // c_null_char)
if (h == 0) error stop "Error: LoadLibrary"
ptr = GetProcAddress(h, "ffun_@8" // c_null_char)
if (ptr == 0) error stop "Error: GetProcAddress"
call c_f_procpointer(transfer(ptr, c_null_funptr), ffun_ptr)
read *, x, y
print *, ffun_ptr(x, y)
if (FreeLibrary(h) == 0) error stop "Error: FreeLibrary"
end program

View file

@ -0,0 +1,35 @@
module kernel32
use iso_c_binding
implicit none
integer, parameter :: HANDLE = C_INTPTR_T
integer, parameter :: PVOID = C_INTPTR_T
integer, parameter :: BOOL = C_INT
interface
function LoadLibrary(lpFileName) bind(C, name="LoadLibraryA")
import C_CHAR, HANDLE
!GCC$ ATTRIBUTES STDCALL :: LoadLibrary
integer(HANDLE) :: LoadLibrary
character(C_CHAR) :: lpFileName
end function
end interface
interface
function FreeLibrary(hModule) bind(C, name="FreeLibrary")
import HANDLE, BOOL
!GCC$ ATTRIBUTES STDCALL :: FreeLibrary
integer(BOOL) :: FreeLibrary
integer(HANDLE), value :: hModule
end function
end interface
interface
function GetProcAddress(hModule, lpProcName) bind(C, name="GetProcAddress")
import C_CHAR, PVOID, HANDLE
!GCC$ ATTRIBUTES STDCALL :: GetProcAddress
integer(PVOID) :: GetProcAddress
integer(HANDLE), value :: hModule
character(C_CHAR) :: lpProcName
end function
end interface
end module