Bind(c) for procedures with complicated derived types

Daniel Franke franke.daniel@gmail.com
Wed Jun 3 22:28:00 GMT 2009


On Wednesday 03 June 2009 23:58:12 John McFarland wrote:
> So I would rephrase my question again as: with the working code example
> I showed previously, is there any way to have the compiler write the
> name of the function "init_object" as "init_object" instead of
> "__fmod_MOD_init_object", without modifying the subroutines (we don't
> mind adding BIND(C), but since the subroutines must accept derived types
> that are not themselves "interoperable", it doesn't seem like an option
> with gfortran)?

In another mail of this thread you mentioned that you wouldn't mind patching 
the compiler. There's a routine in trans-*.c doing the name-mangling, find it 
and skip the mangling, i.e. return the input name. Done. However, keep in mind 
that 

MODULE a
CONTAINS
  SUBROUTINE init_object()
  END SUBROUTINE
END MODULE

MODULE b
CONTAINS
  SUBROUTINE init_object()
  END SUBROUTINE
END MODULE

which would in an unpatched case be mangled to '_a_MOD_init_object' and 
'_b_MOD_init_object', would both be non-mangled to 'init_object' (plus/minus 
some leading or trailing underscores). If your project is as big as indicated, 
ask yourself if you can/want to ensure unique procedure names over all 
modules?!

Cheers

	Daniel



More information about the Fortran mailing list