Pointers (Address Variables)
In Fortran, you use the LOC function to extract the address of a variable. (In Win32, all addresses are 4 bytes, so there is no separate LOCFAR function, as there is for 16-bit environments.) Because Fortran does not have a pointer type, the result of the LOC function must be stored in an INTEGER*4 variable or passed as a parameter of type INTEGER*4. Generally, a pointer should be passed by value.
Passing a pointer by value is equivalent to passing what it points to by reference. In the following example, the two subroutine calls push identical data on the stack, and in each case the C routine called should expect an address. The two functions require different parameter declarations.
INTERFACE TO SUBROUTINE pass_addr1 [C] (addr_data) REAL*8 addr_data [REFERENCE] END INTERFACE TO SUBROUTINE pass_addr2 [C] (addr_data) INTEGER*4 addr_data [VALUE] END REAL*8 x INTEGER*4 ptr CALL pass_addr1 (x) ptr = LOC(x) CALL pass_addr2 (ptr)