Skip to content

Add new class StreambufSwitcher #918

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

heavywatal
Copy link

It redirects std::cout/cerr to Rstreambuf during its lifetime. As a trial, I inserted a code to construct an object in RcppExports.cpp for package developers. It works as expected, but std:cout is detected and complained by R CMD check. The definition of StreambufSwitcher may need to be move to somewhere outside the scope of the check. I also don't know how to apply this feature to non-package usage like sourceCpp(). Therefore, please take this PR as a starting point of discussion.

It redirects std::cout/cerr to Rstreambuf during its lifetime.
As a trial, I inserted a code to construct an object in
`RcppExports.cpp` for package developers. It works as expected,
but std:cout is detected and complained by `R CMD check`.
The definition of StreambufSwitcher may need to be move to
somewhere outside the scope of the check. I also don't know how
to apply this feature to non-package usage like `sourceCpp()`.
Therefore, please take this PR as a starting point of discussion.
@eddelbuettel
Copy link
Member

Thanks for filing this. Maybe an initial issue ticket would have been even better, but we have a starting point. This may not be the the final PR on this, but it gets the ball rolling.

@kevinushey
Copy link
Contributor

While this is reasonable, I don't think this will suffice for getting around CRAN checks because regardless R CMD check is still going to see the usages of cout / cerr in the compiled library, even if they're not used at runtime.

The only 'real' way around these CRAN checks is to ensure that any supporting libraries used / compiled alongside the package just don't use std::cout / std::cerr.

@eddelbuettel
Copy link
Member

The time has come close this for inactivity. As proposed, it can't work. No harm donw, and we're of course always open to new proposals.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants