ここ http://lists.r-forge.r-project.org/pipermail/rcpp-devel/2011-August/002667.html にあるまんま
#include "Rcpp.h" using namespace Rcpp; RcppExport SEXP getIntPointer(){ int *test = new int; *test = 6; XPtr<int> retVal(test) ; return retVal ; } RcppExport SEXP doubleIntPointer(SEXP test){ XPtr<int> test2(test) ; return wrap( *test2 * 2 ) ; }
> dyn.load("RcppPointer.so") > (x <- .Call("getIntPointer")) <pointer: 0x2182740> > (y <- .Call("doubleIntPointer", x )) [1] 12 > dyn.unload("RcppPointer.so")