Skip to content

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

2 messages · Pratibha Rana, Dirk Eddelbuettel

#
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.


Thanks
Pratibha
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20120308/a861d248/attachment.html>
2 days later
#
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