This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
c interop update..
- From: "Christopher D. Rickett" <crickett at lanl dot gov>
- To: fortran at gcc dot gnu dot org
- Cc: crasmussen at lanl dot gov
- Date: Tue, 13 Dec 2005 15:35:16 -0700 (MST)
- Subject: c interop update..
after seeing some of the mail come across mentioning the c interop of f03,
i thought i'd give an update.
in addition to the email i sent a while back, i now have the compiler
allowing for the "use, intrinsic :: iso_c_binding" and generating the
appropriate symbols for the named constants that are used as the kind
parameters. i haven't completed the list of the named constants; this is
a fairly trivial thing but is dependent on what the C compiler supports,
so i have stuck to the basic c int, long, float, double, long double, and
the c_ptr and c_funptr derived types. these seem to be working, and the
compiler is correctly enforcing that a bind(c) routine has c
interoperable params.
also, the VALUE attribute appears to be working, at least for the
interoperable kinds that i have implemented. that is, the primitive types
and derived types can be passed between c and fortran either way, or from
fortran to fortran. i've recently been testing this, especially for
derived types, and the results so far are correct. even if fortran is
only given a reference to an object from C, it can still "promote" it to a
by-value parameter if the given fortran procedure calls another procedure
(C or fortran) that expects it by value.
i've added a fair amount of error checking, though there's much more to do
of course. for example, i've added error checking to the declarations of
common blocks and derived types that are bind(c) to make sure fields
within them are interoperable. at this point, the common blocks and
derived types seem to be working. assumed size arrays that i've tested
are working, either as a param or as a global variable. i've recently
been adding symbol attribute checks in check_conflict() to make sure
things like value and allocatable do not go together, etc. there's more
to add here, but that's fairly straight-forward. one thing i'm not
testing (or preventing i should say) is for the params to a bind(c)
procedure to be allocatable, optional, assumed-shape, or fortran
pointers. it is my understanding that this is to be allowed in fortran 2008.
i'm currently working on the procedures that are in the iso_c_binding
module. i'm focusing on the c_ptr ones first, then will move onto the
procpointer ones after i've added the procedure pointer type. these
procedures are being built into libgfortran.
the biggest obstacle left, i'd guess, is the addition of the procedure
pointer to fortran. otherwise, what seems to be left is fairly
straight-forward. i plan on starting the paperwork soon so hopefully i
can submit the changes. also, a colleague of mine, Craig Rasmussen, will
be doing the paperwork also so he can submit some additions also (he'll
have to explain more himself). Craig has been a large help in
implementing the f03 c interop features.
Thanks.
Chris