[Rcpp-devel] Resolving NativeSymbolInfos from Rcpp (revisited)

Dirk Eddelbuettel edd at debian.org
Sat Jul 29 00:29:42 CEST 2017


On 28 July 2017 at 19:14, Iñaki Úcar wrote:
| Hi all,
| 
| I found this interesting thread by Davor Cubranic in which Romain came
| up with a solution for calling a C routine from the 'stats' package:
| http://lists.r-forge.r-project.org/pipermail/rcpp-devel/2010-June/000753.html
| 
| In a nutshell, I would like to do the same, but with a user-provided
| function compiled with Rcpp::cppfunction. Namely,
| 
| 1) get the externalptr
| 2) get the DL_FUNC with R_ExternalPtrAddrFn
| 3) use it
| 
| Thanks to Romain, 2) and 3) are straightforward. The problem is the
| first step. I saw that, if I compile a function like this
| 
| > Rcpp::cppFunction("int foo() { return 1; }")
| 
| then I can obtain the externalptr with
| 
| > getNativeSymbolInfo("sourceCpp_ID_foo")
| 
| but the problem is that you have to figure out this ID. Is there a
| general way to obtain the name of the native symbol that Rcpp
| produces? (Also I suppose that the initial "sourceCpp_" part could
| change in the future).

I recall that clever trick.

The problem is that R Core really does not want us to access such unexported
access points.

Dirk

-- 
http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org


More information about the Rcpp-devel mailing list