[Rd] R_alloc problems in R v1.11
Thomas Lumley
tlumley at u.washington.edu
Wed Jul 6 23:04:25 CEST 2005
On Wed, 6 Jul 2005, [iso-8859-1] Marie-Hélène Ouellette wrote:
> Dear Dr. Ripley,
Or possibly other people on the list.
> I'm using the R v1.11 on Macintoch
Unlikely. There is no R v1.11, and R 1.1.1 (following the most common
misspelling) wasn't available for the Mac.
> and I seem to have a problem with the
> function R_alloc. It crashes when using the following .C function (only an
> example):
>
> ///////////////////////////////
> # include <R.h>
> void Hello(int *n)
> {
> int i,x;
> for(i=1;1< *n ; i++)
This is an infinite loop. You probably mean i<*n as the second
expression, or perhaps i<=*n (did you want n or n-1 repeats?)
> {
> Rprintf('salut!!!\n');
This is invalid C, as your compiler should have told you. You need double
quotes.
> }
> x = (int *) R_alloc(5,sizeof(int));
x was declared as int, not int *, so again this is invalid.
> }
>
> ///////////////////////////////
>
> I call it in R with this line:
>
> .C('Hello',as.integer(5))
>
> Any idea why and how I can resolve this problem?
After fixing the C errors and in a version of R that exists (2.0.1) I get
> dyn.load("hello.so")
> .C('Hello',as.integer(5))
salut!!!
salut!!!
salut!!!
salut!!!
[[1]]
[1] 5
-thomas
More information about the R-devel
mailing list