[Rd] Portability of a C function

Dirk Eddelbuettel edd at debian.org
Sun Feb 14 13:22:07 CET 2010


On 14 February 2010 at 12:58, Christophe Genolini wrote:
| Hi the list,
| 
| In a package P1, I write a function f1 in C, potentially an internal 
| function (not to be called from R).
| In a package P2, I write a function f2 in C. The f2 function needs to 
| use f1 from P1. Is it possible ?

Yes. See 'Writing R Extension' on LinkingTo. You can register f1 for use by
the others, if P2 has a LinkingTo: on P1 then you're good.  The 'classic'
example is for lme4 using (large) parts of Matrix.

Dirk
 
| --- 8< ---- In file P1.c ---------
| double f1(x,y){
|    ....
| }
| 
| --- 8< ---- In file P2.c ---------
| void f2(x,y,z){
|    double result;
|    ....
|    result = f1(x,y);
|    ....
| }
| 
| Thanks
| Christophe
| 
| ______________________________________________
| R-devel at r-project.org mailing list
| https://stat.ethz.ch/mailman/listinfo/r-devel

-- 
  Registration is open for the 2nd International conference R / Finance 2010
  See http://www.RinFinance.com for details, and see you in Chicago in April!



More information about the R-devel mailing list