Skip to content

[R-pkg-devel] best approach to getting an external library to *not* use stdout, stderr, etc.

4 messages · Simon Barthelmé, Iñaki Ucar

#
Dear list,

I'm trying to wrap an external C++ library that has the bad habit of 
printing errors to std::cerr, a behaviour which will lead to CRAN 
issuing warnings. I was wondering if people had come up with a solution 
to this problem that's better than patching everything by hand?

Thanks

Simon
#
2017-06-28 16:29 GMT+02:00 Simon Barthelm? <simon.barthelme at gipsa-lab.fr>:
Hi, take a look at freopen: http://www.cplusplus.com/reference/cstdio/freopen/

I?aki
#
Hi I?aki

Thanks for the suggestion. I'm not sure how to make it work, though, if 
you call freopen on stderr, R CMD check will still detect a call to 
stderr and trigger a warning. Have you yourself used it?

Best

Simon
On 28/06/2017 17:13, I?aki ?car wrote:
#
2017-06-28 18:34 GMT+02:00 Simon Barthelm? <simon.barthelme at gipsa-lab.fr>:
Not in an R package. Anyways, you can redirect stdout and stderr to
null or even to Rcpp::cout and Rcpp::cerr, but I fear this probably
won't help with the CRAN checks, since the library will still have
symbols writing to stdout and stderr. :-\