[Rd] help with rchk warnings on Rf_eval(Rf_lang2(...))

Lionel Henry ||one| @end|ng |rom r@tud|o@com
Tue Mar 24 11:39:05 CET 2020


> Shield<SEXP> res(Rcpp_fast_eval(Rf_lang2(asEnvironmentSym, x), R_GlobalEnv));

The call should be protected before evaluation though. So more like:

Shield<SEXP> call(Rf_lang2(asEnvironmentSym, x));
return Rcpp_fast_eval(call, R_GlobalEnv);

Best,
Lionel

On 3/23/20, Dirk Eddelbuettel <edd using debian.org> wrote:
>
>
> On 23 March 2020 at 17:07, Ben Bolker wrote:
> | Or is there a way I can use Shield() since this an Rcpp-based project
> | anyway?
>
> Yes you can, and I would recommend it.
>
> Example from Rcpp itself, file Environment.h:
>
>   Shield<SEXP> res(Rcpp_fast_eval(Rf_lang2(asEnvironmentSym, x),
> R_GlobalEnv));
>
> For Rcpp_fast_eval, you may still need to #define RCPP_USE_UNWIND_PROTECT
> before including Rcpp.h; as I recall we were seeing too many side effects
> in
> other packages when globally enabling it.  Or you can play it safe and
> simply
> use Rcpp_eval.
>
> This really was more of a rcpp-devel question.
>
> Dirk
>
> --
> http://dirk.eddelbuettel.com | @eddelbuettel | edd using debian.org
>
> ______________________________________________
> R-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>



More information about the R-devel mailing list