From murdoch.duncan at gmail.com  Sat May 12 00:36:35 2012
From: murdoch.duncan at gmail.com (Duncan Murdoch)
Date: Fri, 11 May 2012 18:36:35 -0400
Subject: [Rd] Replacements for stdout and stderr guaranteed to be open
 in all versions of R
In-Reply-To: <1336772199.2290.27.camel@mabel>
References: <1336772199.2290.27.camel@mabel>
Message-ID: <4FAD9473.8030306@gmail.com>

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



[Rd] Replacements for stdout and stderr guaranteed to be open in all versions of R
Duncan Murdoch