On Mon, Feb 6, 2023 at 6:44 PM Duncan Murdoch <murdoch.dun...@gmail.com> wrote:
> On 06/02/2023 3:46 p.m., Winston Chang wrote: > > I recently submitted a package to CRAN with "SystemRequirements: C++11". > > This raises the following NOTE on R-devel, and I was asked to fix and > > resubmit: > > > > * checking C++ specification ... NOTE > > Specified C++11: please update to current default of C++17 > > > > If I understand correctly, I have two options, neither of which will > work: > > 1. Remove "SystemRequirements: C++11" entirely. The problem with this is > > that on systems with older versions of R (3.6 and below, I believe), it > may > > try to compile the package with an older C++ standard, which will fail. > > 2. Update it to "SystemRequirements: C++17". The problem here is that on > > systems that don't have a C++17 compiler, the package won't build -- even > > though the package only actually requires a C++11 compiler. > > > > How should I deal with this? > > After reading the discussion here and the manuals, I think this is how > to do it. I'm assuming your code is compatible with both C++11 and > C++17, but not some earlier standards. > > 1. In SystemRequirements, state that it needs C++11 or higher. That > field is supposed to be human readable (though I think there are scripts > that try to read it; maybe they will suggest a particular wording to use). > > 2. Have a configure script (e.g. like the one Ivan posted) that > specifies CXX_STD=CXX11 in Makevars if the R version is less than 4.0.0, > and gives no specification otherwise (because from 4.0.0 onwards, if C++ > is available, it will be C++11 or higher). > > I think it wouldn't hurt to look through the available versions and pick > from them, but I don't think it's supposed to be necessary. > > If it eventually turns out that your code is not compatible with some > later standard, I'm sure CRAN will let you know. Now that I think about it some more, I think I can do the following: 1. In the DESCRIPTION file, remove "SystemRequirements: C++11". I believe this field is used only for R CMD check, not for actually installing packages. CRAN only runs R CMD check on r-oldrel, r-release, and r-devel, and all of those versions (4.1, 4.2, and 4.3) have C++11. For older versions of R, the package might not pass R CMD check, but it will still install (provided there's a C++11 compiler). 2. In my case, I think I can skip the configure script. This is because I also have GNU Make as a requirement, and it allows you to conditionally set the CXX_STD variable only when R < 4.0, by putting this in the Makevars file: R_VERSION=$(shell $(R_HOME)/bin/Rscript --vanilla -e 'if (getRversion()<4) cat("lt4") else cat("ge4")') ifeq ($(R_VERSION), lt4) CXX_STD=CXX11 endif -Winston [[alternative HTML version deleted]] ______________________________________________ R-package-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel