So I'm working on this package that uses C++11 via Rcpp. Its DESCRIPTION has "SystemRequirements: C++11" and the files in question have "// [[Rcpp::plugins(cpp11)]]" at the top. And the whole things build fine. Despite all that, the syntax highlighting tells me that it's never heard of C++11 constructions like "std::unordered_map". Now, clearly the compiler has, because everything works. So how do I persuade RStudio (1.1.383) to provide diagnostics for this version of C++ rather than the previous one? Where does it take its cue for syntax highlighting?
Thanks for the bug report! I think this is an incompatibility between RStudio and newer versions of R -- we set the environment variable USE_CXX1X
behind the scenes to request usage of the C++11 standard, but newer versions of R only recognize USE_CXX11
. We'll try to get this fixed up!
In the meantime, I believe you can work around this by setting
USE_CXX11 = yes
in your .Renviron
file, at ~/.Renviron
.
I have this same problem, unfortunately, when I tried USE_CXX11 = yes
in my .Renviron
file, syntax highlighting stopped working altogether. It would be great to have a solution!
Thanks! That's useful. Shall I assume the same arrangement for C++14?
Yes indeed! For what it's worth, this is documented in the R Extension manual -- see https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Using-C_002b_002b14-code.