From edd at debian.org  Sun Feb 14 13:22:07 2010
From: edd at debian.org (Dirk Eddelbuettel)
Date: Sun, 14 Feb 2010 06:22:07 -0600
Subject: [Rd] Portability of a C function
In-Reply-To: <4B77E567.4060603@u-paris10.fr>
References: <4B77E567.4060603@u-paris10.fr>
Message-ID: <19319.60143.344943.662687@ron.nulle.part>


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!



[Rd] Portability of a C function
Dirk Eddelbuettel