[Rd] Interfacing R and C++
Sean Davis
sdavis2 at mail.nih.gov
Mon Jan 9 20:54:53 CET 2006
I have a single c++ file that contains a class and a "wrapper" function that
has C-like syntax for interacting with the Class. Basically, this wrapper
function just makes an instance of the class and then organizes the data for
return to R.
#include <math.h>
void myFunc(double *data, int *n, double *prm, double* intervals, int* max,
double *plot) {
...
}
myClass::myclass(...) {
...
}
My question is simple: what goes inside the extern "C" {} block. Should it
include only the #includes, those and the "wrapper" function, or the entire
.cc file? The answer wasn't clear to me from the Writing R extensions
manual (probably due to my c++ ignorance--using someone else's code).
> sessionInfo()
R version 2.2.0, 2005-08-11, powerpc-apple-darwin7.9.0
attached base packages:
[1] "methods" "stats" "graphics" "grDevices" "utils" "datasets"
[7] "base"
I'm trying to use the .C interface and getting segmentation faults--probably
a bug in the code, but just wanted to make sure that it wasn't a simple
issue with the extern block.
Thanks,
Sean
More information about the R-devel
mailing list