My problem comes in this way:
module proto implicit none public type, abstract :: tp1 contains private generic, public :: ge => sub procedure(Isub), pass, deferred :: sub generic, public :: operator(==) => sub end type tp1 abstract interface function Isub(this, a) import tp1 logical :: Isub class(tp1), intent(in) :: this class(*), intent(in) :: a end function Isub end interface end module proto module inst use proto implicit none private public :: tp2 type, extends(tp1) :: tp2 integer :: s contains private procedure, pass :: sub end type tp2 contains function sub(this, a) implicit none logical :: sub class(tp2), intent(in) :: this class(*), intent(in) :: a integer :: tmp select type(a) type is(integer) tmp = a class default tmp = 0 end select if(this % s == tmp)then sub = .true. else sub = .false. end if return end function sub end module inst program main use inst type(tp2) :: t if(t == 12) write(*,*) "yes" ! FirstLine: This is bad. if(t % ge(12)) write(*,*) "yes" ! SecondLine: This is good. end
When comments out the FirstLine in main, compiler says nothing, but When comments out the SecondLine, the FirstLine generates a link error says unresoved external symbol _PROTO_mp_SUB.
And in addtion, if I do not use operator == but another self-defined operator(anyone, here assume .op.), both FirstLine and SecondLine work normally. Did I misused it? Thanks in advance for any suggestion.