From jeff.a.ryan at gmail.com  Sun Feb 14 23:47:13 2010
From: jeff.a.ryan at gmail.com (J Ryan)
Date: Sun, 14 Feb 2010 16:47:13 -0600
Subject: [Rd] Portability of a C function
In-Reply-To: <4B786890.5080101@u-paris10.fr>
References: <4B77E567.4060603@u-paris10.fr> <4B77E932.2090401@dbmail.com>
	<4B786890.5080101@u-paris10.fr>
Message-ID: <AB84EAAD-E0DB-48C2-B60B-024DDB7E2F23@gmail.com>

Take a look here, as this may help clear up the unanswered questions:

https://stat.ethz.ch/pipermail/r-devel/2008-November/051262.html

HTH
Jeff

Jeffrey A. Ryan
jeffrey.ryan at insightalgo.com

ia: insight algorithmics
www.insightalgo.com

On Feb 14, 2010, at 3:18 PM, Christophe Genolini <cgenolin at u- 
paris10.fr> wrote:

> Thanks, this helps a lot.
>
> So if I understand correctly:
> in package P1, I want to export printMatrix and printMatrixInt. In  
> my file P1.c, I have to add
>
> void R_init_P1(DllInfo *info){
>   R_registerCCallable("longitudinalData","printMatrix",printMatrix);
>   R_registerCCallable 
> ("longitudinalData","printMatrixInt",printMatrixInt);
> };
>
>
> In P2.c, I have to add :
>
> void R_init_P2(DllInfo *info){
>   printMatrix = R_GetCCallable("longitudinalData","printMatrix");
>   printMatrixInt = R_GetCCallable 
> ("longitudinalData","printMatrixInt");
> };
>
>
> I still have a problem here: "Writing R ext" say that 'printMatrix'  
> and 'printMatrixInt' should have "an appropriate declaration". What  
> is the appropriate declaration?
>
> Christophe
>
>
>> Hello,
>>
>> This was discussed this week in the thread "LinkingTo and C++".
>>
>> It is possible, and documented in WRE section 5.4 : http://cran.r-project.org/doc/manuals/R-exts.html#Registering-native-routines
>>
>> Romain
>>
>> On 02/14/2010 12:58 PM, 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 ?
>>>
>>> --- 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



[Rd] Portability of a C function
J Ryan