On 5/28/2014 23:58, Matteo Fasiolo wrote:
Dear Rcpp developers,

I am working on a package <https://github.com/mfasiolo/mvnfast> which uses Rcpp/RcppArmadillo, OpenMP and C++11.

Everything works fine under Linux: the package passes R CMD check --as-cran,
while tests and vignettes work fine.

I uploaded the package on win-builder, but I keep getting the error at the bottom.

I have included the line CXX_STD = CXX11 in makefile.win as written in "Writing R extensions". I have read comments on SO <http://stackoverflow.com/questions/18971177/building-r-package-with-c11-rcpp-on-windows> regarding Rtools not supporting many C++11
features. Is that the reason for the error or am I missing something?
Hi, it's fixable! :-)

I remember having to do that for RcppArmadillo 0.4.200.0.
Just updated to RcppArmadillo 0.4.300.0 and the issue still appears.

There are two reasons (and thus two quick fixes):

- "\RcppArmadillo\include\armadillo_bits\compiler_setup.hpp" forces the C++11 mode even when the compiler only supports experimental C++0x (this explains your diagnostic messages);

a simple fix is to comment out the offending preprocessor directives -- as in the following:

  //#if defined(__GXX_EXPERIMENTAL_CXX0X__)
  //  #undef  ARMA_USE_CXX11
  //  #define ARMA_USE_CXX11
  //#endif

- "\RcppArmadillo\include\RcppArmadilloConfig.h" tries to detect Windows environment and fails (as already noticed). IMHO it fails for a good reason -- the guaranteed define is `_WIN32` and not `WIN32`.

// As Dirk noted the `WIN32` attempt is due to the choice made by R implementers in the past. This doesn't change the fact that this choice is wrong, IMHO -- the reason is that only the leading underscore (with certain capitalization variants, also other names with `_t`, etc.) is guaranteed to result in a name that is an implementation-reserved choice in C and C++. OTOH, names like `WIN32` are not reserved and the users (client code) may feel free to (re)define them as they like -- in particular, Windows users may freely `#undef` it, while POSIX users may freely `#define` it -- and there's no reason to say they would be "wrong" in doing so ;-)
//
// See:
// http://stackoverflow.com/questions/662084/whats-the-difference-between-the-win32-and-win32-defines-in-c // http://stackoverflow.com/questions/228783/what-are-the-rules-about-using-an-underscore-in-a-c-identifier

A better fix may be to fix the offending line in "RcppArmadilloConfig.h", perhaps to something like the following:
#if defined(WIN32) || defined(_WIN32)

After applying these fixes, an example from http://cran.r-project.org/web/packages/Rcpp/vignettes/Rcpp-attributes.pdf (p.6; BTW, there's a small typo: using-directive statement is missing a semicolon terminator) using RcppArmadillo compiles without issues.

HTH,

Best,

Matt


_______________________________________________
Rcpp-devel mailing list
Rcpp-devel@lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Reply via email to