Steve Lianoglou wrote: > When I use inline for anything semi-permanent (the last step before > turning it into a package, let's say), I typically have a thin R > wrapper function that calls down to my inline function and I never > call the inline function directly anywhere else. The job of the thin R > wrapper function is to sanity check and/or coerce the vars to the > correct type before they are past to the inline'd function to avoid > the segfault. (I've pasted in below an example, from you, from another thread to show what you mean.)
Why do you do this in R, instead of in the C++ function? (The advantage of doing it in the C++ function is that there is no way to accidentally skip the validation.) Darren my_f <- function(x) { if (!(is.integer(x) && length(x) == 1L)) stop("Illegal value for `x`) f(x_=x) } f <- cxxfunction(signature(x_="integer"), plugin = "Rcpp", ' int x = as<int>(x_); // ... ') _______________________________________________ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel