[Rcpp-devel] C++11 in Windows R package

Matteo Fasiolo matteo.fasiolo at gmail.com
Thu May 29 22:54:53 CEST 2014


Hi Matt,

 many thanks, I'm happy to see that there is a solution.

I was going to go through the armadillo source code, but I would never have
found the offending #if defined(__GXX_EXPERIMENTAL_CXX0X__).

Matteo


On Thu, May 29, 2014 at 8:28 PM, Dirk Eddelbuettel <edd at debian.org> wrote:

>
> On 29 May 2014 at 20:41, Matt D. wrote:
> | On 5/28/2014 23:58, Matteo Fasiolo wrote:
> |
> |     Dear Rcpp developers,
> |
> |      I am working on a package 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 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
>
> Ack. I need to coordinate with Conrad to make this a little less binding.
>  He
> is tad busy right now but we should get there.  Maybe (for now) just using
>
>      #if defined(__GXX_EXPERIMENTAL_CXX0X__) && !defined(_WIN32)
>
> to protect ourselves from g++ 4.6.* is good enough?
>
> | - "\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)
>
> Yes, that is simpler than what I had committed in the meantime -- will
> adjust.
>
> | 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.
>
> Thanks, added the semicolon too.
>
> Dirk
>
> --
> Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com
> _______________________________________________
> Rcpp-devel mailing list
> Rcpp-devel at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20140529/aa2ae0ef/attachment.html>


More information about the Rcpp-devel mailing list