J3/00-283 Date: 19 Sep 2000 To: J3 From: R. Maine Subject: Unresolved issue 257 (C functions) Reeferences: J3/00-217 This paper is a revision of 00-217, which was written, but not reviewed or acted on at the previous meeting. 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 procedure interfaces with C function prototypes. This material is much like the comparison of Fortran and C types in its level of abstraction. EDITS to 00-007r2 [392:19,25] "C function" -> "C function prototype". [392:31,34,36,38] "C function" -> "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 prototype or (b) the interface describes a subroutine, and the prototype has a result type compatible with the C type void;" [392:30] "Fortran procedure" -> "interface" [393:11] "function with an" -> "procedure" [393:19] Replace the whole line with "is interoperable with the C function 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:342+] [394:1-] Add the following note at the end of 16.2.6 "Note 16.xx The interopability of Fortran procedure interfaces with C function 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 function prototype, and the C function. Conversely, invocation of a Fortran procedure from C involves the function reference, the C function prototype, the Fortran procedure interface, and the Fortran procedure. 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 C function 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 procedure 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 function prototype. The C function is not shown here, but is assumed to be compatible with the C function 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."