Le 18/11/2014 16:39, Romain François a écrit :

Le 18 nov. 2014 à 14:42, Serguei Sokol <serguei.so...@gmail.com> a écrit :

/* call this R command: source("FileName") */
    int errorOccurred;
    SEXP e = lang2(install("source"), mkString("FileName"));
        /* mkChar instead of mkString would lead to this runtime error:
         * Error in source(FileName) : unimplemented type 'char' in 'eval' */
    R_tryEval(e, R_GlobalEnv, &errorOccurred);

e is not protected here. Does the problem go away if you protect it:

SEXP e = PROTECT( lang2(install("source"), mkString("FileName"))) ;
you mean
SEXP e = PROTECT(lang2(install("source"), mkChar("expm.higham.R")));
(because mkString() had no problem)?
No, it does not, the problem is still there.



Or more R/C++ idiomatically, which is both nicer and safer.

Language e( "source", "FileName" ) ;
This works as expected. We can suppose that behind the stage
"FileName" is wrap()-ed here with mkString() and not with mkChar().
That's why it's working.


which suggests that somewhere in Rcpp or RcppArmadillo there is
a mkChar() call instead of mkString().

Other times, error message can say something like
"argument type[1]='x' must be one of 'M','1','O','I','F' or 'E'"
or "argument type[1]='character' must be a one-letter character string"
This latter message is somewhat volatile per se. The part of message
just after "type[1]=" can be 'character' (as above) or 'method' or 'ANY' etc.

That kind of problem usually is related to premature GC.
I will try "gctorture(TRUE)" suggested by Martin.

Thanks,
Serguei.
_______________________________________________
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

Reply via email to