[Rcpp-devel] How to handle std::cout/std::cerr in shared libraries

Dirk Eddelbuettel edd at debian.org
Fri Oct 26 15:12:11 CEST 2018


On 26 October 2018 at 22:03, Watal M. Iwasaki wrote:
| Dear Dirk,
| 
| Thank you for the prompt response. Good to know there is no easy way. I
| have made up my mind to change the library code as you suggested. But I
| don't like preprocessor macro; therefore, the problem here was solved by
| moving/hiding `std::cout.rdbuf()` part into the library as a function that
| takes a streambuf pointer, and just calling it from Rcpp side. Now, output
| is properly sent to R console, R CMD check complains nothing, and the
| library still remains free from R/Rcpp code. Thanks again.

Nicely done.

We could do with a more general solution to this. If you have ideas ...

Dirk

-- 
http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org


More information about the Rcpp-devel mailing list