Skip to content

Instantly share code, notes, and snippets.

@kbroman
Created June 24, 2015 19:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kbroman/8ea364ffe12ca24b5113 to your computer and use it in GitHub Desktop.
Save kbroman/8ea364ffe12ca24b5113 to your computer and use it in GitHub Desktop.
#include <Rcpp.h>
using namespace Rcpp;
// [[Rcpp::export]]
void r_message(std::string text)
{
Rcpp::Function msg("message");
msg(text);
}
/*** R
r_message("not suppressed")
suppressMessages(r_message("suppressed"))
message("not suppressed")
suppressMessages(message("suppressed"))
*/
@kbroman
Copy link
Author

kbroman commented Jun 24, 2015

How do message() and suppressMessages() work in R, and why can't I call message() from within C++ and then suppress it?

> Rcpp::sourceCpp("r_message.cpp")

> r_message("not suppressed")
not suppressed

> suppressMessages(r_message("suppressed"))
suppressed

> message("not suppressed")
not suppressed

> suppressMessages(message("suppressed"))

@kbroman
Copy link
Author

kbroman commented Jun 24, 2015

I discussed this with @eddelbuettel in October: RcppCore/Rcpp#195
At that point, suppressMessages() was working on the C++ call to message(), but it's not working for me now. 😦

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment