On 30 November 2020 at 17:06, Mark Clements wrote: | [Apologies for cross-posting] | | A colleague uses a package I maintain (rstpm2) as a dependency in their | package (rsimsum) with testing using GitHub Actions. They found that | testing failed against R versions 3.3, 3.4 and 3.5 because recent | versions of RcppArmadillo (which is a dependency in rstpm2) require | C++11. As a dependency diagram: | | rsimsum --> rstpm2 --> RcppArmadillo | | Should I update rstpm2 to include "CXX_STD = CXX11" in the Makevars and | Makevars.win files and add "SystemRequirements: C++11" to the | DESCRIPTION, or is there a simple way in GitHub Actions to use C++11 for | older versions of R?
Yes. Writing R Extension has the goods, as usual: ----------------------------------------------------------------------------- 1.2.4 Using C++11 code ---------------------- R can be built without a C++ compiler although one is available (but not necessarily installed) on all known R platforms. As from R 4.0.0 a C++ compiler will be selected only if it conforms to the 2011 standard ('C++11'). A minor update(1) ('C++14') was published in December 2014. A revision ('C++17') was published in December 2017, and a further revision ('C++20', with many new features) is scheduled for publication in May 2020. What standard a C++ compiler aims to support can be hard to determine: the value(2) of '__cplusplus' may help but some compilers use it to denote a standard which is partially supported and some the latest standard which is (almost) fully supported. The webpage <http://en.cppreference.com/w/cpp/compiler_support> gives some information on which compilers are known to support recent C++ features. 'g++' claims full C++11 support from version 4.8.1. As from version 3.6.2(3), R selects a default C++ compiler with options that conform as far as possible(4) to C++11. Packages which do not specify 'R (>= 4.0)' in their 'DESCRIPTION' files need to explicitly require C++11, hence the rest of this section. In order to specify C++11 code in a package to be used with R versions from 3.1.0 but before 3.6.2, the package's 'Makevars' file (or 'Makevars.win' on Windows) should include the line CXX_STD = CXX11 Compilation and linking will then be done with the C++11 compiler (if any). Packages without a 'src/Makevars' or 'src/Makefile' file may specify that they require C++11 for code in the 'src' directory by including 'C++11' in the 'SystemRequirements' field of the 'DESCRIPTION' file, e.g. SystemRequirements: C++11 If a package does have a 'src/Makevars[.win]' file then setting the make variable 'CXX_STD' is preferred, as it allows 'R CMD SHLIB' to work correctly in the package's 'src' directory. [... rest omitted ...] ----------------------------------------------------------------------------- | Moreover, as a principle, should a package need to change the Makevars | and DESCRIPTION files to suit the most recent updates of their | dependencies? I would have thought that such a need would break many | packages. I don't understand what you are trying to say. R, as shown in the quote, supports C++11 and even defaults to it. What would break anywhere? Dirk -- https://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org ______________________________________________ R-package-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel