J3/06-102 Date: 24 November 2005 To: J3 From: Aleksandar Donev Subject: C interop of dummy procedures NUMBER: F03/0073 TITLE: C interop of dummy procedures KEYWORDS: Interoperability, dummy procedures DEFECT TYPE: ERRATUM STATUS: J3 consideration in progress QUESTION: Is the following interface interoperable, and if yes, what is the interoperable C prototype? use iso_c_binding subroutine my_sub(my_fun) bind(c, name="My_Proc") interface function my_fun(x) bind(c) use iso_c_binding integer(c_int) :: my_fun real(c_double), value :: x end function end interface end subroutine ANSWER: Yes, this interface is interoperable with the following protype: void My_Sub(int (*my_fun)(double)) or equivalently (according to the C standard) void My_Sub(int my_fun(double)) Item (5) in the list in section 15.2.6 seems to have been written with only data objects in mind, and it is not clear whether it applies to dummy procedures. I quote it here: (5) any dummy argument without the VALUE attribute corresponds to a formal parameter of the prototype that is of a pointer type, and the dummy argument is interoperable with an entity of the referenced type (C International Standard, 6.2.5, 7.17, and 7.18.1) of the formal parameter; We believe that the intention is that dummy procedures be included, and that this text should be revised accordingly. EDITS: In item (5) in the list in section 15.2.6, replace "any dummy argument without the VALUE attribute" with "any dummy argument that is not a procedure and does not have the VALUE attribute" and replace "pointer type" with "object pointer type". and add a new item (5+) to the list: (5+) any dummy procedure argument corresponds to a formal parameter of the prototype that is of function pointer type, and the dummy procedure is interoperable with a function of the referenced type of the formal parameter; SUBMITTED BY: Aleksandar Donev HISTORY: J3/06-102 at meeting 175