<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">On 5/28/2014 23:58, Matteo Fasiolo
wrote:<br>
</div>
<blockquote
cite="mid:CAC_0WE_yNhn_NzKsXjW63TBCg3TGDYawTCWEJ9Ey0hyA+O-QnA@mail.gmail.com"
type="cite">
<div dir="ltr">Dear Rcpp developers,
<div><br>
</div>
<div> I am working on a <a moz-do-not-send="true"
href="https://github.com/mfasiolo/mvnfast">package</a> which
uses Rcpp/RcppArmadillo, OpenMP and C++11.</div>
<div><br>
</div>
<div>Everything works fine under Linux: the package passes R CMD
check --as-cran,</div>
<div>while tests and vignettes work fine.</div>
<div><br>
</div>
<div>I uploaded the package on win-builder, but I keep getting
the error at the bottom.</div>
<div><br>
</div>
<div>
<div>I have included the line CXX_STD = CXX11 in makefile.win
as written in "Writing<br>
</div>
<div>R extensions". I have read comments on <a
moz-do-not-send="true"
href="http://stackoverflow.com/questions/18971177/building-r-package-with-c11-rcpp-on-windows">SO</a> regarding
Rtools not supporting many C++11</div>
<div>features. Is that the reason for the error or am I
missing something?</div>
</div>
</div>
</blockquote>
Hi, it's fixable! :-)<br>
<br>
I remember having to do that for RcppArmadillo 0.4.200.0.<br>
Just updated to RcppArmadillo 0.4.300.0 and the issue still appears.<br>
<br>
There are two reasons (and thus two quick fixes):<br>
<br>
- "\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);<br>
<br>
a simple fix is to comment out the offending preprocessor directives
-- as in the following:<br>
<br>
//#if defined(__GXX_EXPERIMENTAL_CXX0X__)<br>
// #undef ARMA_USE_CXX11<br>
// #define ARMA_USE_CXX11<br>
//#endif<br>
<br>
- "\RcppArmadillo\include\RcppArmadilloConfig.h" tries to detect
Windows environment and fails (as already noticed).<br>
IMHO it fails for a good reason -- the guaranteed define is `_WIN32`
and not `WIN32`.<br>
<br>
// 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 ;-)<br>
//<br>
// See:<br>
//
<a class="moz-txt-link-freetext" href="http://stackoverflow.com/questions/662084/whats-the-difference-between-the-win32-and-win32-defines-in-c">http://stackoverflow.com/questions/662084/whats-the-difference-between-the-win32-and-win32-defines-in-c</a><br>
//
<a class="moz-txt-link-freetext" href="http://stackoverflow.com/questions/228783/what-are-the-rules-about-using-an-underscore-in-a-c-identifier">http://stackoverflow.com/questions/228783/what-are-the-rules-about-using-an-underscore-in-a-c-identifier</a><br>
<br>
A better fix may be to fix the offending line in
"RcppArmadilloConfig.h", perhaps to something like the following:<br>
#if defined(WIN32) || defined(_WIN32)<br>
<br>
After applying these fixes, an example from
<a class="moz-txt-link-freetext" href="http://cran.r-project.org/web/packages/Rcpp/vignettes/Rcpp-attributes.pdf">http://cran.r-project.org/web/packages/Rcpp/vignettes/Rcpp-attributes.pdf</a>
(p.6; BTW, there's a small typo: using-directive statement is
missing a semicolon terminator) using RcppArmadillo compiles without
issues.<br>
<br>
HTH,<br>
<br>
Best,<br>
<br>
Matt<br>
<br>
<br>
</body>
</html>