C++11 with R and Rcpp: supported by CRAN policies?
Asked Answered
S

1

9

This blog entry by Dirk Edelbuettel states:

Rcpp, as a CRAN package, follows CRAN policy in not (yet at least) supporting this standard [C++11] for its purported non-portable status.

The blog entry is two years old, and I've been wondering if this is still true (both with regard to the CRAN policies, where I did not find any hint about C++11, and Rcpp support).

Moreover, I would like to know what this means exactly. I used a CXX_STD = CXX11 statement in the src/MAKEVARS file (rather than Sys.setenv("PKG_CXXFLAGS"="-std=c++11") as proposed in the blog entry). This seems to work with the C++11 features I am using (mainly the tgamma function), Rcpp, and R. But will I get ripleyed when I submit my package to CRAN? Will the package not be available for some operating systems?

Sparteine answered 1/2, 2015 at 11:46 Comment(5)
This is all detailed in the Writing R Extensions manual, see particularly Section 1.2.4 entitled Using C++11.Lamblike
I have read and complied with the instructions in this section of the manual. But your article referred to the CRAN policies, not the Writing R Extensions manual, which are two different things, IMHO. Or was this just imprecise and that's all?Sparteine
Have you read the Rcpp FAQ? There is a reason we wrote it as there is commonality between your question(s) and what has been asked before many, many times. Also please consider using the rcpp-devel mailing list instead of this. Viel Glueck.Lamblike
Thanks for the hint, I was not aware of the Rcpp FAQ and the rcpp-devel list. I was searching thoroughly on Stackoverflow and did not find answers, so I found it legitimate to ask (sorry if I misinterpreted this as a Q&A platform). With regard to the Rcpp FAQ: where does it state that a) both R and the package employing Rcpp must be compiled with the same compiler version and b) CRAN policies do not reject packages with C++11 anymore? Thanks in advance for pointing me to the right entry. The only thing I found there was: The default compilers on all the common platforms are suitable.Sparteine
Always better to go to the source rather than relying solely on 'searching thoroughly on Stackoverflow'. a) & b) should both be available in Writing R Extensions (which is canon) along with the CRAN Policies. Both are available from the R project site and from our own r tag info page.Immaterialize
L
10

All of the above comments, and try:

// [[Rcpp::plugins(cpp11)]]

There are several packages which require C++11, search CRAN for SystemRequirements: C++11, and Rcpp. E.g. http://cran.us.r-project.org/web/packages/contoureR/index.html which has about the simplest possible package configuration without using Rcpp::plugins(cpp11).

My case is peculiar because, for obscure CRAN maintainer reasons, on esoteric platforms, OpenMP and C++11 don't go together (see https://github.com/jackwasey/icd for how to accomplish this with a configure script).

Lara answered 3/10, 2015 at 20:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.