[Fortran-Experiments] Nested interface blocks with Bind(c)

Christopher D. Rickett crickett@lanl.gov
Sat Feb 24 02:39:00 GMT 2007


hi Tobias,

> the following valid code is rejected:
> -------------------------------------
> MODULE OpenGL_glut
> IMPLICIT NONE
>
> INTERFACE
>   FUNCTION glutCreateMenu(func) BIND(C,NAME="glutCreateMenu")
>     use iso_c_binding
>     INTEGER :: glutCreateMenu
>     INTERFACE
>       SUBROUTINE func() BIND(C)
>       END SUBROUTINE func
>     END INTERFACE
>   END FUNCTION glutCreateMenu
> END INTERFACE
> END MODULE OpenGL_glut
> -------------------------------------
>
> I think in order to make it fully work, one needs procedural pointers,
> but at least the current error message could be improved:
>
> test3.f90:9.31:
>       SUBROUTINE func() BIND(C)
>                               1
> Error: Syntax error in BIND(C) statement at (1)
>
> Maybe one could get this part also working without procedural pointers.
> (I haven't thought about this in detail.)

i copied this code and tried it on my local gfortran and it produces the
following output:

tobias1.f03:5.30:

  FUNCTION glutCreateMenu(func) BIND(C,NAME="glutCreateMenu")
                             1
Error: BIND(C) attribute conflicts with DUMMY attribute at (1)
tobias1.f03:10.9:

      END SUBROUTINE func
        1
Error: Expecting END INTERFACE statement at (1)
tobias1.f03:5.30-25:

  FUNCTION glutCreateMenu(func) BIND(C,NAME="glutCreateMenu")
                        2    1
Warning: Implicity declared variable 'func' at (1) may not be C
interoperable but it is a dummy argument to the BIND(C) procedure
'glutcreatemenu' at (2)

i'm not sure what caused the 'Syntax error ...'.  i've updated some of the
error messages and handling, and perhaps my copy is too far out of date. 
i'll send a patch soon.  however, it still seems like a bug in gfortran,
since the dummy is a procedure.  also, i'm not sure what happened to the
warning that should have been generated for "glutCreateMenu" possibly not
being C interoperable since it is declared of type default integer.

thanks for the testing.
Chris




More information about the Fortran mailing list