J3/14-257 To: J3 From: Malcolm Cohen Subject: C_F_POINTER fixups Date: 2014 October 13 1. Introduction The C_F_POINTER extension introduced by the interop TS has poor wording. There are no examples of C_F_POINTER to help understand the three cases. 2. Edits to 14-007r2 In 15.2.3.3 C_F_POINTER, p3 Arguments, CPTR argument, [445:11] After "data entity", delete "or" [445:12] After "noninteroperable argument", change "." -> ", or". [445:12+] Add new bullet point "- the C address of a storage sequence that is not in use by any other Fortran entity". Same para, FPTR argument, [445:16-19] Make this Case (i). [445:20-24] Make this Case (ii). [445:25-446:2] Make this Case (iii). [445:25] After "address of a storage sequence" insert "that is not in use by any other Fortran entity", [445:27-446:1] Delete ", shall not ... entity,". [446:4++] After the NOTE 15.3 "... placement in memory.", insert examples "Examples. Case (i): extern double c_x; void *address_of_x(void) { return &c_x; } ! Assume interface to "address_of_x" is available. Real(C_double), Pointer :: xp Call C_F_Pointer (address_of_x(), xp) Case (ii): Type t Real,Allocatable :: v(:,:) End Type Type(t), Target :: x Type(C_ptr) :: xloc xloc = C_Loc(x) ... Type(t), Pointer :: y Call C_F_Pointer(xloc, y) Case (iii) void *getmem(int nbits) { return malloc((nbits+CHAR_BIT-1)/CHAR_BIT); } ! Assume interface to "getmem" is available, ! and there is a derived type "mytype" accessible. Type(mytype), Pointer :: x Call C_F_Pointer(getmem(Storage_Size(x)), x)" ===END===