From jon.clayden at gmail.com  Fri Mar 16 12:30:59 2012
From: jon.clayden at gmail.com (Jon Clayden)
Date: Fri, 16 Mar 2012 11:30:59 +0000
Subject: [Rd] Dealing with printf() &c. in third-party library code
In-Reply-To: <4F628DDE.9060808@fhcrc.org>
References: <CAM9CR=2iwS1E3TFnh5y-SRCh5p3KEtSD1ChO7bVpXgMsRV_PrQ@mail.gmail.com>
	<4F61786B.6030200@fhcrc.org>
	<CAM9CR=2493iX8V4-5WXSC4461WoSVkWY_USs+J=RAYTCS-gY0w@mail.gmail.com>
	<4F628DDE.9060808@fhcrc.org>
Message-ID: <CAM9CR=2pnNcJsrtW1H3AMgG4-C8m9PFQaMpF4i=N34E=SxJSiA@mail.gmail.com>

On 16 March 2012 00:48, Martin Morgan <mtmorgan at fhcrc.org> wrote:
> On 03/15/2012 02:24 PM, Jon Clayden wrote:
>>
>> Martin,
>>
>> Thanks for your reply. I wonder if you'd be willing to post your
>> "my_fprintf" function, since I'm struggling to get around needing to
>> use the "stdout" and "stderr" symbols completely. This function has
>> the right effect...
>>
>> void rniftyreg_fprintf (FILE *stream, const char *format, ...)
>> {
>> ? ?va_list args;
>> ? ?va_start(args, format);
>>
>> ? ?if (stream == stdout)
>> ? ? ? ?Rvprintf(format, args);
>> ? ?else if (stream == stderr)
>> ? ? ? ?REvprintf(format, args);
>> ? ?else
>> ? ? ? ?vfprintf(stream, format, args);
>>
>> ? ?va_end(args);
>> }
>>
>> ... but the R CMD check info message still arises because stdout and
>> stderr still appear. I'm struggling to see how to get around this
>> without doing something really ugly, like casting integers to FILE*
>> pointers.
>
>
> Hi Jon --
>
> My own implementation is like yours, where I still reference stderr /
> stdout. But it seems like the meaningful problem (writing to stderr /
> stdout, which R might have re-directed) has been addressed (except for the
> third branch, in your code above).

Yes, this certainly deals with the important issue - the check note
becomes a false positive. I need the third branch to allow things to
work properly for fprintf calls which write to actual files...

Thanks again,
Jon



[Rd] Dealing with printf() &c. in third-party library code
Jon Clayden