Skip to content

Instantly share code, notes, and snippets.

Last active March 30, 2023 20:29
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wch/849ca79c9416795d99c48cc06a44ca1e to your computer and use it in GitHub Desktop.
Save wch/849ca79c9416795d99c48cc06a44ca1e to your computer and use it in GitHub Desktop.
How to deal with R-devel C++17 warning

How to deal with the SystemRequirements: C++11 NOTE when running R CMD check

For the development version of R-devel which will become 4.3.0, there is a new warning in R CMD check that comes up for some packages:

* checking C++ specification ... NOTE
  Specified C++11: please drop specification unless essential

(In earlier versions of R-devel, it said please update to current default of C++17.)

Link to the code that generates the NOTE.

CRAN is now asking to fix and resubmit packages which raise this NOTE.

This happens when the package's DESCRIPTION file has the following:

SystemRequirements: C++11

Packages that use C++11 generally would also have the following in the src/Makevars and src/ files (and src/Makevars.ucrt, if present):


This tells R to use the C++11 standard when compiling the code.

To understand the NOTE, a bit of history will be helpful:

  • In R 3.5 and below, on systems with an old compiler, it would default to using the C++98 standard. If a package needed a C++11 compiler, the DESCRIPTION file was supposed to have SystemRequirements: C++11, and the src/Makevars, src/, and src/Makevars.ucrt files needed to have CXX_STD=CXX11. However, systems with newer compilers appear to default to C++11, even without setting CXX_STD.
  • In R 3.6.2, it defaulted to compiling packages with the C++11 (if the compiler supported C++11 -- and in practice, essentially all systems by that time had a C++11 compiler).
  • In R 4.0, it required a C++11 compiler, so SystemRequirements: C++11 was no longer necessary.
  • In (the forthcoming) R 4.3, it raises a NOTE if SystemRequirements: C++11 is present, which will block a package submission to CRAN.

How to fix it

  1. Edit the DESCRIPTION file and remove SystemRequirements: C++11.
  2. Edit src/Makevars, src/, and src/Makevars.ucrt and remove CXX_STD=CXX11.

After making these changes, the package should install without trouble on R 3.6 and above. However, on R 3.5 and below, there may be systems where it won't build (these are systems with very old compilers on them). Note that in my testing on GitHub Actions, with R 3.5 on Ubuntu 20.04 and 22.04, packages using C++11 build just fine. But on systems with older compilers, it could potentially be a problem.

If you want to be confident that your package to still be installable on R 3.5 and below with older compilers, then you need to use a configure script at the top level of the package, and have it add CXX_STD=CXX11 for R 3.5 and below.

Copy link

ateucher commented Feb 8, 2023

I think something like this would work if you don't already have src/Makevars/src/, or configure.R could be modified to write the entire contents if you do... Adapted from here.

If you require building on R <= 3.5.x, you must specify CXX_STD=CXX11 in
src/Makevars on those systems. One way to do this is to create the following files
that check the R version and if it < 3.6.2, sets that flag in Makevars. This assumes you
don't already have src/Makevars and/or src/ already.


exec "${R_HOME}/bin/Rscript" tools/configure.R

exec "${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe" tools/configure.R


rm -vf src/Makevars



if (getRversion() < '3.6.2') {
  fname = file.path('src', 'Makevars')
  f <- file(fname, 'wb')
  writeLines("CXX_STD=CXX11", f)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment