[Rcpp-devel] Rprintf equivalent for std::cout ?

Dirk Eddelbuettel edd at debian.org
Sun Nov 11 17:51:36 CET 2012

On 11 November 2012 at 17:34, Steffen Neumann wrote:
| Hi,
| I am not certain the question in the subject 
| is grammatically correct. Nevertheless, R and Bioconductor 
| are more and more complaining about symbols it doesn't like [1],
| such as printf, exit, std::cerr or std::cout. 

CRAN got strict on that a while back, yes.
| While the former are rather simple to search&replace 
| with Rprintf or something equivalent, I am looking for Rcpp streams
| which are the equivalent to cout and cerr, e.g.
| 	Rcpp::rout << "Hi world" << std::endl;
| or	Rcpp::rerr << "Damn, s**t hit the fan!" << std::endl;

>From the NEWS entry for release 0.9.8:

    \item Applied patch by Jelmer Ypma which adds an output stream class
        'Rcout' not unlike std::cout, but implemented via Rprintf to
       	cooperate with R and its output buffering.

We will have a new release 0.9.16 "real soon now" and will also have Rcerr
thanks to something Romain put into SVN today.

| I need that if I want to wrap 3rd party source code
| that was not written with being part of an R library 
| in first place. Boost stuff comes to mind here ...
| I'd love to be able to 
| find . -type f -exec sed -i -e 's/std::cerr/Rcpp::rerr/g' \{\} \;
| to fix that. Or did I miss anything obvious ?

That may still fail _as a global substitution_ as we do not have all iostream
manipulators implemented.  Contributions would be welcomed!


Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com  

More information about the Rcpp-devel mailing list