This is the mail archive of the
mailing list for the GCC project.
Re: [Patch,Fortran] Update gfortran.texi for mixed-language programming
2009/6/3 Tobias Burnus <firstname.lastname@example.org>:
> Currently, gfortran does not allow OPTIONAL with BIND(C), but one only
> needs to change a single "if" to "implement" it (when TR 29113 allows
> it). Using standard Fortran 2003, implementing this OPTIONAL trick
> oneself is nontrivial due to the type checking Fortran.
That's nice to know - I had to resort to provide C-interoperable
Fortran wrappers for our functions that have optional arguments, i.e.
one that passes none, one that passes optional argument foo, ... PITA
> Actually I did include this - not as bullets, but I think I mentioned
> all your points (OPTIONAL in the TR 29113 section, unsigned integers
> (unsigned char is a special case of integers), bitfields, VLA, unions,
> variable function arguments) in the text.
You sure did - I shamelessly copied many parts from your writing.
My point is not that you forgot anything, but that I would like to
*additionally* have a concise list of them in one place to serve as
> Well, they do work - you just have to make sure the integer size is the
> same. Otherwise "int", "int32", "integer" and "integer(c_int)",
> "integer(c_int32)" should be most of the time equivalent.
Good point - but why not use the documentation to 'educate' your users
to use this stuff properly?
I agree that "does not work" is too strong a formulation and a
downright lie (and you should not lie to your users) - maybe "should
not be used"?
> I think I mentioned that quite explicitly. The point is: You can still
> pass a string to a "character(len=1),dimension(*)". Thus such an item
> without mentioning in some way the storage equivalence is misleading.
I agree this can and should be rephrased - education again :-)
> Well, depends whether you pass it to a "dummy(:)" or to a "dummy(*)". In
> the former case an array descriptor (dope vector) is passed; in the
> latter a pointer to foo(5) is passed and - if needed - the array is
> copied to a contiguous temporary array. Only the latter is allowed for
Sorry, if I wasn't clear enough - I meant, can one pass foo(5:8) to a
C function (probably with a C-interop Fortran interface definition)?
> NOTE to self: I really need to mention somewhere that C's
> ? array[n][m]
> matches Fortran's
Might be helpful! :-)