[R] .C and character

Torsten Hothorn (hothorn@amadeus.statistik.uni-dortmund.de)
Thu, 25 Mar 1999 14:29:13 +0100 (MET)

Date: Thu, 25 Mar 1999 14:29:13 +0100 (MET)
From: Torsten Hothorn <hothorn@amadeus.statistik.uni-dortmund.de>
To: r-help@stat.math.ethz.ch
Subject: [R] .C and character

Hi,

I had a problem passing characters from R into c-code by dyn.load() and .C().

test.c:
void R2Cdouble(double *db)
{
printf("\n my double: %f \n", db[0]);
}

test.R:
dyn.load("mylib.so");
.C("R2Cdouble", as.double(0.5));

worked fine, but

test1.c:
void R2Cstr(char *str)
{
printf("\n my char: %s \n", str[0]);
}

test1.R:
dyn.load("mylib.so");
.C("R2Cdouble", as.character("test"));

caused a segmentation fault (Linux 2.0.36, R-0.62.4).

Is there a mechanism to do that?

Torsten

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


This archive was generated by hypermail 1.02.