[Rd] Registration of native routines

Gregor Gorjanc gregor.gorjanc at bfro.uni-lj.si
Thu Mar 1 11:39:24 CET 2007

Dear R developers,

I am working on registration of native C and FORTRAN routines and have
encountered "inconsistencies" about this issue. I am referring to
"Registering native routines" section of R-ext manual.


On line 5108 of R-ext.texi the array for method myCall is defined as

  {"myCall", &myCall, 3},

but looking at examples in src/library/stats/src/init.c I notice
addition of (DL_FUNC) i.e. upper definition would be

  {"myCall", (DL_FUNC) &myCall, 3},

This probably shows my poor knowledge of C, but what is the role of
(DL_FUNC)? Looking around the code I notice that DL_FUNC is used also in
other places. IMHO I would suggest that (DL_FUNC) is also "mentioned" in
the manual.

Additionally, what is the role of &F77_SUB() in registration of FORTRAN
subroutines i.e. the following line is one example from

    {"lowesw", (DL_FUNC) &F77_SUB(lowesw), 4}

src/main/registration.c for example uses &F77_SYMBOL() instead of
&F77_SUB(). Poking around the source I see that this is related to _. I
would again suggest to add this to the manual.

*Type and style field

For .C() and .Fortran() manual says that registration array can also
hold type and style fields. It is shown how type field should look like,
but nothing usable is said about style except

<manualSays>Typically, one omits this information in the registration

Why would one omit this if

<manualSays>The purpose is to allow @R{} to transfer values more
efficiently across the R-C/FORTRAN interface by avoiding copying values
when it is not necessary.</manualSays>?

Thank you!


More information about the R-devel mailing list