[Rcpp-devel] Can Rcpp::InternalFunction have a variadic function as the argument

Dirk Eddelbuettel edd at debian.org
Sat Mar 10 21:59:37 CET 2012


On 8 March 2012 at 10:55, Pratibha Rana wrote:
| Hi,
| 
| I'm trying to do something like this :
| 
| void RLogger(const char *format,...)
| {
|   va_list ap;
|   va_start(ap,format);
|   mylogger.write("R Log:",format, ap);
|   va_end(ap);
| 
| }
| 
| int main(int argc, char *argv[])
| {
|    RInside RGlobal;
|    RGlobal["my_log"] = Rcpp::InternalFunction(&RLogger);
|    return go(argc, argv);
| }
| 
| 
| 
| But this doesn't compile. I get the following error
| 
| error: initializing argument 1 of ‘Rcpp::InternalFunction::InternalFunction
| (OUT (*)(U0)) [with OUT = void, U0 = const char*]’
| 
| 
| I was wondering if the variadic functions are allowed in the
| InternalFunction, because it works if I have a single argument.

Please feel free to adapt the existing code to suit your needs if the
interface we provide does not provide everything you require.  

And please keep in mind that most things are done from an R perspective using
its SEXP interface, not necessarily from a C++ perspective with function
pointers, lambdas, ...  

There may well be room for careful extensions.

Dirk
 
 
| Thanks
| Pratibha
| 
| ----------------------------------------------------------------------
| _______________________________________________
| Rcpp-devel mailing list
| Rcpp-devel at lists.r-forge.r-project.org
| https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
-- 
"Outside of a dog, a book is a man's best friend. Inside of a dog, it is too
dark to read." -- Groucho Marx


More information about the Rcpp-devel mailing list