[R] Calling C Code from R
Gabor Csardi
csardi at rmki.kfki.hu
Wed Jul 4 13:48:12 CEST 2007
On Wed, Jul 04, 2007 at 04:39:18AM -0700, Deb Midya wrote:
> Hi R Users,
>
> Thanks in advance.
>
> I am using R-2.5.1 on Windows XP.
>
> I am trying to call C code (testCX1.C) from R. testCX1.c calls another C code (funcC1.c) and returning a value to testCX1.c. I like to have this value in R.
>
> My steps are below:
>
> 1. R CMD SHLIB testCX1.c funcC1.c (at command propmt)
>
> 2. It creates testCX1.dll with warning (but testCX1.dll works):
>
> testCX1.c:38: warning: implicit declaration of function 'func'
>
> How to get rid off this error ?
By adding the prototype of 'func' to testCX1.c:
SEXP func(SEXP a);
Probably it is simplest to collect all prototypes in a single header file
and include that from all .c files.
> What is the best way to call funcC1.c from testCX1.c?
See .C and .Call and in particular the 'Writing R Extensions' manual,
5 System and foreign language interfaces.
Gabor
[...]
--
Csardi Gabor <csardi at rmki.kfki.hu> MTA RMKI, ELTE TTK
More information about the R-help
mailing list