[Rcpp-devel] CRAN note about std::cout in shared library

Dirk Eddelbuettel edd at debian.org
Tue Feb 7 12:45:01 CET 2023


Hi Kassel,

On 7 February 2023 at 02:57, Kassel Hingee wrote:
| I'm running into CRAN check notes about std::cout being present in the Cpp code of a library I'm using.
| 
|     Found ‘_ZSt4cout’, possibly from ‘std::cout’ (C++)
| 
| It looks like Rcpp is automatically redirecting the std::cout stream to Rcout, which is very handy and to my (shallow) understanding, solves the CRAN concern about where output from the package goes. However, I'm still getting the above CRAN check note.
|
| Does anyone know if CRAN will ignore this note, or if there is a way to avoid it without modifying the library?

There are two things here.  Years ago Rcpp got a clever pull request adding
Rcpp::Rcout and Rcpp::Rcerr.  We can (mostly) use these in lieu of std::cout
and std::cerr, and output will be redirected to R's as if Rprintf() and
REprintf() had been used as Writing R Extensions demands / suggests. We still
benefit from that PR.

So far so good. But in code you link against, you still need to ensure that
that code does not use std::cout etc either!  And that appears to have
happened here. And more or less the only choice you have is to find where
that use happens and to comment it out or alter it. There is no automated
solution or magic here, sadly.

Cheers, Dirk

-- 
dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org


More information about the Rcpp-devel mailing list