From mel at altk.com  Fri Apr 20 12:09:56 2007
From: mel at altk.com (mel)
Date: Fri, 20 Apr 2007 12:09:56 +0200
Subject: [Rd] printf capture
In-Reply-To: <097DF923-E961-4707-B29C-81F3C85B9461@r-project.org>
References: <461E02EE.7040105@altk.com>
	<Pine.LNX.4.64.0704121122480.26905@gannet.stats.ox.ac.uk>
	<461E3F8F.4050801@altk.com>
	<Pine.LNX.4.64.0704121558260.11792@gannet.stats.ox.ac.uk>
	<46277D42.9080203@altk.com>
	<097DF923-E961-4707-B29C-81F3C85B9461@r-project.org>
Message-ID: <46289174.7090904@altk.com>

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 !
Thanks
Vincent



[Rd] printf capture
mel