[Rd] Replacements for stdout and stderr guaranteed to be open in all versions of R
Duncan Murdoch
murdoch.duncan at gmail.com
Sat May 12 00:36:35 CEST 2012
On 12-05-11 5:36 PM, David Sterratt wrote:
> I maintain the geometry package, which integrates the Qhull C library
> (http://qhull.org) into R. The Qhull function I hook into requires an
> open FILE handle as one of its arguments. I had set this file handle to
> stdout, but now R check NOTEs the presence of stdout, and the CRAN
> maintainers asked me to get rid of these NOTEs.
>
> Including the following defines means the checks are passed on CRAN:
>
> #ifdef WIN32
> extern FILE * R_Consolefile;
> extern FILE * R_Outputfile;
> #else
> #include<Rinterface.h>
> #fi
> #undef stderr
> #define stderr R_Consolefile
> #undef stdout
> #define stdout R_Outputfile
>
> However, this does not work on Rgui.exe, when the above leads to a
> crash. Looking at
> http://svn.r-project.org/R/trunk/src/gnuwin32/system.c
> it would appear that R_Consolefile and R_Outputfile only point to open
> files when CharacterMode == RTerm, not in GUI mode.
>
> Therefore my question is, are there any replacements for stdout and
> stderr that work across all versions of R?
I'm pretty sure the answer is "no". What you can do is have your
initialization code open a new handle (pointing to something that is not
stdout, e.g. a file), and then pass that to the Qhull function.
Duncan Murdoch
More information about the R-devel
mailing list