On 8 May 2012 at 23:17, Jiqiang Guo wrote: | Suppose I have a function in CPP as | | void cppfun(Rcpp::List lst) { | ...... | } | | Then I would like to call this cppfun in R code as say | cppfun(list(a=a, b=b, c=c, ...)), in which
(Well you need a SEXP somefun(SEXP ...) interface from R) | a, b, c could be of different types and their type might be different as this | function gets called another time. So I would like to know the type of a, b, | c in the CPP code. Could someone help me out or point to me some other | approaches? Thanks. It's a good question. I have at time thought about that a little, but have no immediate solution for you. One could possible use something C++-ish via traits. One could also use C level macros from the R API which simply test for types as after all each element of a List must be a SEXP, so we use the SEXP-style macros. In the end I always went with more explicit code design: only use a List for transfer to / from R, and otherwise use explicit C++ types. Dirk -- R/Finance 2012 Conference on May 11 and 12, 2012 at UIC in Chicago, IL See agenda, registration details and more at http://www.RinFinance.com _______________________________________________ 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