From: James Van Buskirk on
"Eli Osherovich" <eli.osherovich(a)gmail.com> wrote in message
news:3b331431-4ea7-4034-80dd-0ecc996233fc(a)g11g2000yqe.googlegroups.com...

> At the first glance it requires me (as a system writer) to compile a
> plugin and see if it fits the interface. However, the whole idea was
> to remove this step completely.
> I want to provide the interface and get back shared libraries that
> contain implementation of certain plugins. Of course, a plugin writer
> can use your example to check himself I just wanted to automate this
> process as much as possible.

I can't see how it's possible for the compiler (you wanted to do this
at the compilation stage) to tell you that a function doesn't match
a certain interface (or in general if two interfaces match) without
somehow asserting to the compiler that the interfaces match according
to Fortran rules and having the compiler tell you what it thinks
about that assertion.

After all, it's possible for many procedure with non-matching
interfaces to happily coexist in a standard-conforming program as
long as they aren't supposed to be replacements for one another.
So you have to try to make them replacements for one another as
shown in my examples. It's not necessary to compile both or even
either interface each time you want to do the checking. If you
split out interfaces and just compile against the *.mod files
created when the interfaces are compiled you still get the
error detection:

C:\gfortran\clf\ifacechk>type A.f90
module iface
implicit none
abstract interface
function obj_f(x, flag) result(res)
real :: res
real, intent(in), dimension(2) :: x
real, intent(in), optional :: flag
end function obj_f
end interface
end module iface

C:\gfortran\clf\ifacechk>type B.f90
module plugins
implicit none
contains
function colins_plugin(x)
use iface
implicit none
real, intent(in) :: x(2)
real colins_plugin

colins_plugin = x(1)
end function colins_plugin
end module plugins

C:\gfortran\clf\ifacechk>type ifacechk2.f90
program test
use iface
use plugins
use ISO_C_BINDING, only: C_F_PROCPOINTER, C_NULL_FUNPTR
implicit none
procedure(obj_f), pointer :: fpA
procedure(colins_plugin), pointer :: fpB

if(.FALSE.) then
call C_F_PROCPOINTER(C_NULL_FUNPTR,fpA)
fpB => fpA
end if
end program test

C:\gfortran\clf\ifacechk>gfortran -Wall -c A.f90

C:\gfortran\clf\ifacechk>gfortran -Wall -c B.f90

C:\gfortran\clf\ifacechk>gfortran -Wall ifacechk2.f90 A.o B.o -oifacechk2
ifacechk2.f90:11.13:

fpB => fpA
1
Error: Interface mismatch in procedure pointer assignment at (1): 'fpa' has
the
wrong number of arguments

--
write(*,*) transfer((/17.392111325966148d0,6.5794487871554595D-85, &
6.0134700243160014d-154/),(/'x'/)); end