6

The following doesnt compile in Intel Fortran XE 2011:

TYPE type1
    procedure(interface1),POINTER::p
END TYPE type1

ABSTRACT INTERFACE 
    integer function interface1(a)
        real,intent(in)::a    
    END function interface1
END INTERFACE

The error:

error #8262: The passed-object dummy argument must be dummy data object with the same declared type as the type being defined.
Johannes Gerer
  • 25,508
  • 5
  • 29
  • 35

1 Answers1

8

Add the nopass attribute to the declaration of the procedure pointer component.

procedure(interface1), pointer, nopass :: p

Edit: In response to your comment, if you want to use the pass keyword, the interface would have to be changed as such:

ABSTRACT INTERFACE 
    integer function interface1(passed_object, a)
        import :: type1
        class(type1), intent(...) :: passed_object
        real,         intent(in)  :: a
    END function interface1
END INTERFACE
eriktous
  • 6,569
  • 2
  • 25
  • 35
  • Thanks! Would you mind explaining, why this solves my problem? – Johannes Gerer Mar 31 '11 at 18:12
  • Without explicitly specifying the `nopass` attribute, the component automatically has the `pass` attribute (which can also be specified explicitly). This means that the first dummy argument of the procedure should be of the same type as the type being defined (as stated in your error message). When referring to the procpointer component, the object through which it is invoked is automatically passed as the first argument. – eriktous Mar 31 '11 at 18:21
  • How would I need to change `interface1` if I wanted to use the `pass` keyword? – Johannes Gerer May 04 '11 at 10:46
  • @user578832: I've updated my answer in response to your question. – eriktous May 04 '11 at 12:59