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

Tobias Burnus burnus@net-b.de
Fri Feb 23 13:44:00 GMT 2007


Hi,

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.)


Found when compiling f03gl, http://www-stone.ch.cam.ac.uk/pub/f03gl/.
Even with that part fixed, "C_FUNLOC" is missing.
Maybe given a better error message for C_FUNLOC than
   Error: Function 'c_funloc' at (1) has no IMPLICIT type
would be useful, too. (Ditto for C_F_PROCPOINTER().)

I don't know whether one can get C_FUNLOC working without procedural
pointers. (C_FUNLOC accepts either "a procedure that is interoperable,
or a procedure pointer associated with an interoperable procedure".
Maybe the first part is possible without the second?)

Using NAG f95 the examples work and are quite impressive.

Tobias



More information about the Fortran mailing list