J3/00-217 Date: 31 May 2000 To: J3 From: R. Maine Subject: Unresolved issue 257 (C functions) Unresolved issue 257 points out that the discussion of interoperation with C functions is confusing. This paper attempts to clarify the issue. One source of confusion is that the current draft is a lack of clear distinction between abstract and concrete situations. There is material defining when a C function and a Fortran procedure are interoperable, but this material is abstract in that a given program would not actually have both the Fortran procedure and the C function in question. This gets particularly confusing when syntactic conditions (like "is declared with") are put on things that don't actually exist. I find it easier to follow if this material is phrased in terms of comparing Fortran interfaces with C prototypes. This material is much like the comparison of Fortran and C types in its level of abstraction. EDITS (These edits incorporate and override those of 00-216 where they overlap) [392:19,25,31,34,36] "C function" -> "C prototype". [392:19,25] "procedure" -> "procedure interface" (twice) [392:26] "procedure is declared with" -> "interface has" [392:27-29] replace item (2) with "(2) either (a) the interface describes a function whose result variable is interoperable with the result of the C prototype or (b) the interface describes a subroutine, and the C prototype has a result type compatible with the C type void;" [392:30] "Fortran procedure" -> "interface" [393:34] "function with an" -> "procedure" [393:42] Replace the whole line with "is interoperable with the C prototype" [392:22] Move this line into a new note at [392:37+]. Then change "reference" to "referenced" both here and on [392:37]. (per check of the C standard). [392:19-21] Move this para to [392:38-] [394:7-] Add the following note at the end of 16.2.6 "Note 16.xx The interopability of Fortran procedure interfaces with C prototypes is only one part of invocation of a C function from Fortran. There are four pieces to consider in such an invocation: the procedure reference, the Fortran procedure interface, the C prototype, and the C function. In order to determine whether a reference is allowed, it is necessary to consider all four pieces. For example, consider a C function that can be described by the prototype [copy line from [388:10]] Such function may be invoked from Fortran as follows: [copy [388:12-24]] The procedure reference has character string actual arguments. These correspond to character array dummy arguments in the interface body as allowed by Fortran's rules of sequence association (12.4.1.5). Those array dummy arguments in the procedure interface are interoperable with the formal parameters of the C prototype. The C function is not shown here, but is assumed to be compatible with the prototype." [388:9-24] Replace these lines (after copying most of their content as instructed above" with "Note 16.xx has an example of interoperation bewtween Fortran and C strings."