New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Loading cpp11 has no effect with 3.4.0? #683
Comments
Here's how the
We probably need to change that to |
From a first casual glance I think I can confirm it. It does seem to affect the outcome for me as my default compiler is |
Spot on, @kevinushey. I recall a recent email by Martyn Plummer about this and had some unease about side-effects. This may be one. |
@kevinushey I can confirm that Sys.setenv("USE_CXX1X" = "yes") has no effect on the compilation while Sys.setenv("USE_CXX11" = "yes") makes it work. So the plugin should be setting both then -- one for 3.4.0 and one for earlier versions? |
The plugin is already conditional as @kevinushey showed. And the fix is good. Will commit this is a second: # built-in C++11 plugin
.plugins[["cpp11"]] <- function() {
if (getRversion() >= "3.4") # with recent R versions, R can decide
list(env = list(USE_CXX11 = "yes"))
else if (getRversion() >= "3.1") # with recent R versions, R can decide
list(env = list(USE_CXX1X = "yes"))
else if (.Platform$OS.type == "windows")
list(env = list(PKG_CXXFLAGS = "-std=c++0x"))
else # g++-4.8.1 or later
list(env = list(PKG_CXXFLAGS ="-std=c++11"))
} |
I've dug around the R source a bit to understand how it came to this: The change wch/r-source@45899db turned, among other things, This change was not backward-compatible: Prior to the change you had to set one, afterwards you had to set the other, and failing to adjust caused the setting to have no effect at all. Before the 3.4.0 release then there was another commit, wch/r-source@628448b, where this issue was recognised and addressed. This change, however, affected only variables set in etc/Makeconf.in (like I cannot comment on whether this was an oversight or deliberate but had the latter been given a similar treatment, this issue would not have come up. @eddelbuettel I've tested your feature branch and it fixes my problem, thank you. This issue can now be closed from my point of view but since you might prefer to leave it open until a merge, a release, or something else, I'll refrain from closing it myself. |
Nice digging, and there also was an announcement by Martyn. The 'not backwards compatible' is a bit unusual. OTOH the main setting via And yes, plan to merge now that I have a thumbs-up from another Rcpp team member (thanks as always, @kevinushey). |
Correcting CXX11 etc env vars for R 3.4.0 or later (closes #683)
Please consider the following sample code:
I believe with R 3.3.3, this worked as expected: The function
std::hypot
is new with C++11 but loading thecpp11
plugin made it available.Now I'm on R 3.4.0 and the code does not work anymore. Instead, here's what I get:
In other words, the function
std::hypot
is not found. There could be many reasons for that. My first reaction was that I need to include<cmath>
now. But that doesn't make the error go away. Instead, what does make the error go away is loadingcpp14
instead ofcpp11
. What also makes the error go away is manually settingSo my impression is that Rcpp somehow things my C++ compiler is already in C++11 mode by default so that the cpp11 plugin needn't do anything. But that's not so.
This is the compiler that I'm using (provided by the g++ package on debian 8.7):
Finally, my session info:
Update: It could not reproduce this issue on macOS 10.12, only linux; I would assume that /usr/bin/c++ indeed defaults to C++11 mode there already.
The text was updated successfully, but these errors were encountered: