[Rcpp-devel] Rcpp example that crashes on 64 bit Windows
Dirk Eddelbuettel
edd at debian.org
Thu Aug 11 18:28:58 CEST 2016
On 11 August 2016 at 11:05, Rajen Shah wrote:
| I realise there is a helpful section on this in
|
| https://cran.r-project.org/doc/manuals/r-release/R-exts.html#
| Checking-memory-access
|
| which I'm now reading.
We generally shield you from this. That is, you create objects without
having to worry about. But a) casts (particularly implicit ones) and b) the
wrap() return business are really complicated.
If you err on the side of caution everything works:
R> cppFunction("IntegerVector myrunif() { NumericVector x = floor(runif(1000000)); return as<IntegerVector>(x); }")
R> for (i in 1:100) ignoreme <- myrunif()
R>
Here we start with the numeric vector, then cast to an integer vector which
is what is returned.
Dirk
--
http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org
More information about the Rcpp-devel
mailing list