简体   繁体   中英

Calling C function from R, pass opaque pointer

I have read several tutorials on calling C functions from R, but none of these examples demonstrate how to pass/return an opaque pointer to C. That is, suppose I have a C API like

struct foo *foo_new();
void foo_destroy(struct foo *);

How would I expose such an API to R?

I believe only limited types of arguments are supported while calling the C functions.

According to manual:

R storage mode  C type          FORTRAN type

logical         int *           INTEGER
integer         int *           INTEGER
double          double *        DOUBLE PRECISION
complex         Rcomplex *      DOUBLE COMPLEX
character       char **         CHARACTER*255
raw             unsigned char * none

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM