[Rd] printf capture

mel mel at altk.com
Fri Apr 20 12:09:56 CEST 2007

Simon Urbanek a écrit :

> The wrapper:
> #include <R.h>
> int printf(const char *format, ...) {
>   va_list (ap);
>   va_start(ap, format);
>   Rvprintf((char*)format, ap);
>   va_end(ap);
>   return 0;
> }
> If you link this in your project (simply create a separate object file 
> with this), the project will be using Rprintf via this wrapper instead 
> of printf from libc. Note that you shouldn't be relying on the return 
> value literally, otherwise you're in trouble ;).
> Cheers,
> Simon

Thanks for the code.
The idea seems indeed interesting/appropriate for my needs.
I didn't remember at all that one could redefine
functions such as printf().
seems i need a good C/C++ brush up !

More information about the R-devel mailing list