Keep calm and #include <Rcpp11>

June 19, 2014
By

(This article was first published on R Enthusiast and R/C++ hero, and kindly contributed to R-bloggers)

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 his blog: R Enthusiast and R/C++ hero.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.