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

Jon Clayden jon.clayden at gmail.com
Fri Mar 16 12:30:59 CET 2012


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



More information about the R-devel mailing list