Prev: f2003 compilers?
Next: error - what is unit 9001
From: M.S. Breitenfeld on 12 Jan 2010 17:54 I have this extracted test program that compiles with intel, g95, suns,and pgi compilers. But it fails with gfortran 4.3,4.4,4.5.It gives the error: FUNCTION test_genprop_cls_cb1_f(create_data) bind(C) 1 Error: Type 'create_data' at (1) is a parameter to the BIND(C) procedure 'test_genprop_cls_cb1_f' but is not C interoperable because derived type 'myftype' is not C interoperable MODULE test_genprop_cls_cb1_mod ! Callback subroutine IMPLICIT NONE CONTAINS FUNCTION test_genprop_cls_cb1_f(create_data) bind(C) USE ISO_C_BINDING IMPLICIT NONE INTEGER(C_INT) :: test_genprop_cls_cb1_f TYPE :: myftype INTEGER(C_INT) :: count INTEGER(C_INT) :: id END TYPE myftype TYPE(myftype) :: create_data test_genprop_cls_cb1_f = 1 END FUNCTION test_genprop_cls_cb1_f END MODULE test_genprop_cls_cb1_mod PROGRAM main END PROGRAM main
From: steve on 12 Jan 2010 18:12 On Jan 12, 2:54 pm, "M.S. Breitenfeld" <msbrtn...(a)gmail.com> wrote: > I have this extracted test program that compiles with intel, g95, > suns,and pgi compilers. But it fails with gfortran 4.3,4.4,4.5.It gives > the error: > > FUNCTION test_genprop_cls_cb1_f(create_data) bind(C) > 1 > Error: Type 'create_data' at (1) is a parameter to the BIND(C) > procedure 'test_genprop_cls_cb1_f' but is not C interoperable because > derived type 'myftype' is not C interoperable http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40920
From: Reinhold Bader on 12 Jan 2010 18:13 Hello, Am 12.01.2010 23:54, schrieb M.S. Breitenfeld: > I have this extracted test program that compiles with intel, g95, > suns,and pgi compilers. But it fails with gfortran 4.3,4.4,4.5.It gives > the error: > > FUNCTION test_genprop_cls_cb1_f(create_data) bind(C) > 1 > Error: Type 'create_data' at (1) is a parameter to the BIND(C) > procedure 'test_genprop_cls_cb1_f' but is not C interoperable because > derived type 'myftype' is not C interoperable Well, the error message describes the issue with the code pretty well - the standard's prescription for all C-interoperable procedure indeed is that all dummy arguments must be interoperable. An entity of derived type is interoperable only if the type definition includes a BIND(C) as follows: TYPE, BIND(C) :: myftype INTEGER(C_INT) :: count INTEGER(C_INT) :: id END TYPE myftype (and of course all type components must then be interoperable in turn). This by the way does not necessarily imply that it isn't possible to deal somehow with non-interoperable entities. It does however mean that some extra effort will be needed - for example by using type(c_ptr) entities and the c_loc() intrinsic to generate *void C pointers, effectively creating a handle to your non-interoperable entity which can be passed through C code. Regards Reinhold > > MODULE test_genprop_cls_cb1_mod > > ! Callback subroutine > IMPLICIT NONE > CONTAINS > FUNCTION test_genprop_cls_cb1_f(create_data) bind(C) > USE ISO_C_BINDING > IMPLICIT NONE > INTEGER(C_INT) :: test_genprop_cls_cb1_f > TYPE :: myftype > INTEGER(C_INT) :: count > INTEGER(C_INT) :: id > END TYPE myftype > TYPE(myftype) :: create_data > test_genprop_cls_cb1_f = 1 > END FUNCTION test_genprop_cls_cb1_f > END MODULE test_genprop_cls_cb1_mod > PROGRAM main > END PROGRAM main
From: Reinhold Bader on 12 Jan 2010 18:17 Am 13.01.2010 00:12, schrieb steve: > On Jan 12, 2:54 pm, "M.S. Breitenfeld" <msbrtn...(a)gmail.com> wrote: >> I have this extracted test program that compiles with intel, g95, >> suns,and pgi compilers. But it fails with gfortran 4.3,4.4,4.5.It gives >> the error: >> >> FUNCTION test_genprop_cls_cb1_f(create_data) bind(C) >> 1 >> Error: Type 'create_data' at (1) is a parameter to the BIND(C) >> procedure 'test_genprop_cls_cb1_f' but is not C interoperable because >> derived type 'myftype' is not C interoperable > > > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40920 I see: gfortran is buggy in that it also rejects the corrected version of OP's code. This doesn't change the fact that OP's code is not conforming. Regards Reinhold
From: Richard Maine on 12 Jan 2010 19:08
steve <kargls(a)comcast.net> wrote: > On Jan 12, 2:54 pm, "M.S. Breitenfeld" <msbrtn...(a)gmail.com> wrote: > > I have this extracted test program that compiles with intel, g95, > > suns,and pgi compilers. But it fails with gfortran 4.3,4.4,4.5.It gives > > the error: > > > > FUNCTION test_genprop_cls_cb1_f(create_data) bind(C) > > 1 > > Error: Type 'create_data' at (1) is a parameter to the BIND(C) > > procedure 'test_genprop_cls_cb1_f' but is not C interoperable because > > derived type 'myftype' is not C interoperable > > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40920 Perhaps I am misreading something, but that bug report doesn't sound like the OP's problem. That bug report says it is about rejecting valid code, where the derived type in question is interoperable. The OP's code, on the other hand, is not valid. It is not a compiler bug to reject it. I would say more the opposite - that it would be a compiler bug to fail to diagnose it. As Reinhold notes, the cited error message seems pretty much on target... well... except for some pretty big terminology errors now that I look at it more closely. The biggest terminology error is that it refers to create_data as a type, which just isn't so at all. I could well imagine that confusing people. There is a problem with the type of create_data, but create_data is not itself a type. The second terminology error is in referring to actual arguments as parameters. The compiler migt be written in C, but it is a compiler for the Fortran language. Its error messages ought to use correct Fortran terminology. There are things in Fortran called parameters; this isn't one of those. -- Richard Maine | Good judgment comes from experience; email: last name at domain . net | experience comes from bad judgment. domain: summertriangle | -- Mark Twain |