[Rd] Difference between .C and .Fortran (on Windows)
Prof Brian Ripley
ripley at stats.ox.ac.uk
Thu Apr 24 16:42:34 MEST 2003
On Thu, 17 Apr 2003, Duncan Murdoch wrote:
> In updating my web page on using non-standard compilers in Windows,
> I've been trying to figure out exactly what the differences are
> between .C() and .Fortran(), but the code is pretty convoluted.
>
> Can someone let me know if the following is correct?
>
> There are two differences between .C("foo", ...) and .Fortran("foo").
>
> 1. .C looks for the symbol "foo" in the external library, whereas
> .Fortran("foo", ...) looks for the symbol "foo_" (which is how g77
> would export the subroutine "foo").
There are symbol.C() and symbol.For() to show you the mappings used.
Not all systems appends an underscore for Fortran, and some
case-convert the Fortran names (to lower, usually but not always).
R does not currently cope with the latter, so there is an assumption
that Fortran symbol names are written in lower case. (That precludes
some Fortran compilers.)
I don't think do_symbol is convoluted, BTW!
> 2. .C passes character mode vectors as a pointer to an array of
> pointers to the strings, whereas .Fortran just passes a pointer to a
> 255 character buffer containing the first string. In both cases the
> strings are null-terminated.
>
> Are there other differences? Are these platform-dependent?
As Thomas noted, arbitrary language objects can be passed through .C.
Also, .Fortran does analogous things on returned strings (which may not be
null-terminated, BTW).
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-devel
mailing list