C_F_PROCPOINTER (The GNU Fortran Compiler)

### 8.58 `C_F_PROCPOINTER` — Convert C into Fortran procedure pointer ¶

Synopsis:

  `CALL C_F_PROCPOINTER(CPTR, FPTR)`

Description:

  `C_F_PROCPOINTER(CPTR, FPTR)` Assign the target of the C function pointer CPTR to the Fortran procedure pointer FPTR.

Class:

  Subroutine

Arguments:

  CPTR | scalar of the type `C_FUNPTR`. It is `INTENT(IN)`.
  FPTR | procedure pointer interoperable with cptr. It is `INTENT(OUT)`.

Example:

      program main
        use iso_c_binding
        implicit none
        abstract interface
          function func(a)
            import :: c_float
            real(c_float), intent(in) :: a
            real(c_float) :: func
          end function
        end interface
        interface
           function getIterFunc() bind(c,name="getIterFunc")
             import :: c_funptr
             type(c_funptr) :: getIterFunc
           end function
        end interface
        type(c_funptr) :: cfunptr
        procedure(func), pointer :: myFunc
        cfunptr = getIterFunc()
        call c_f_procpointer(cfunptr, myFunc)
      end program main

Standard:

  Fortran 2003 and later

See also:

  `C_LOC` — Obtain the C address of an object,
  `C_F_POINTER` — Convert C into Fortran pointer,
  `C_F_STRPOINTER` — Convert C string into Fortran string pointer