Site icon R-bloggers

Keep calm and #include <Rcpp11>

[This article was first published on R Enthusiast and R/C++ hero, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Following up on this post, I have just commited some code that makes the using namespace Rcpp11 ; automatic, I was just tired of typing it. So now, you can just do :

#include <Rcpp11>

If however, for some weird reason (some people love littering their code with Rcpp::) you don’t want the using namespace Rcpp11; to be automatically added, you can either switch to :

#include <Rcpp.h>

or define the RCPP11_DISABLE_AUTOMATIC_USING_NAMESPACE macro before you include <Rcpp11>:

#define RCPP11_DISABLE_AUTOMATIC_USING_NAMESPACE
#include <Rcpp11>

I know that’s a lot of typing, but the idea is to make the most useful pattern (you almost always want to have using namespace Rcpp11 ;) easier than the less useful.

Unsurprisingly, the <Rcpp11> header looks like this:

#ifndef RCPP11_includes
#define RCPP11_includes

#include <Rcpp.h>

#ifndef RCPP11_DISABLE_AUTOMATIC_USING_NAMESPACE
using namespace Rcpp11 ;  
#endif

#endif

To leave a comment for the author, please follow the link and comment on their blog: R Enthusiast and R/C++ hero.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.