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

David Sterratt david.c.sterratt at ed.ac.uk
Fri May 11 23:36:39 CEST 2012


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?

All the best,

David.
-- 
David C Sterratt, Research Fellow. Tel: (+44) 131 651 1739
Institute for Adaptive and Neural Computation
School of Informatics, University of Edinburgh
Informatics Forum, 10 Crichton Street, Edinburgh EH8 9AB, Scotland, UK



More information about the R-devel mailing list