Skip to content

Correcting CXX11 etc env vars for R 3.4.0 or later (closes #683) #684

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

Merged
merged 2 commits into from
Apr 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
2017-04-25 Dirk Eddelbuettel <edd@debian.org>

* R/Attributes.R (.plugins[["cpp11"]]): If R 3.4.0 or newer is used, set
USE_CXX11 (instead of the older USE_CXX1X);
(.plugins[["cpp14"]]): similarly updated for C++14
(.plugins[["cpp17"]]): similarly updated for C++17
(.plugins[["cpp98"]]): added

2017-04-22 Nathan Russell <russell.nr2012@gmail.com>

* inst/include/Rcpp/sugar/functions/strings/trimws.h: Added sugar
Expand Down
25 changes: 20 additions & 5 deletions R/Attributes.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

# Copyright (C) 2012 - 2016 JJ Allaire, Dirk Eddelbuettel and Romain Francois
# Copyright (C) 2012 - 2017 JJ Allaire, Dirk Eddelbuettel and Romain Francois
#
# This file is part of Rcpp.
#
Expand Down Expand Up @@ -456,9 +456,18 @@ compileAttributes <- function(pkgdir = ".", verbose = getOption("verbose")) {
# setup plugins environment
.plugins <- new.env()

# built-in C++11 plugin
# built-in C++98 plugin
.plugins[["cpp98"]] <- function() {
if (getRversion() >= "3.4") # with recent R versions, R can decide
list(env = list(USE_CXX98 = "yes"))
else
list(env = list(PKG_CXXFLAGS ="-std=c++98"))
}
# built-in C++11 plugin
.plugins[["cpp11"]] <- function() {
if (getRversion() >= "3.1") # with recent R versions, R can decide
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"))
Expand All @@ -475,7 +484,10 @@ compileAttributes <- function(pkgdir = ".", verbose = getOption("verbose")) {
## this is the default in g++-6.1 and later
## per https://gcc.gnu.org/projects/cxx-status.html#cxx14
.plugins[["cpp14"]] <- function() {
list(env = list(PKG_CXXFLAGS ="-std=c++14"))
if (getRversion() >= "3.4") # with recent R versions, R can decide
list(env = list(USE_CXX14 = "yes"))
else
list(env = list(PKG_CXXFLAGS ="-std=c++14"))
}

# built-in C++1y plugin for C++14 and C++17 standard under development
Expand All @@ -485,7 +497,10 @@ compileAttributes <- function(pkgdir = ".", verbose = getOption("verbose")) {

# built-in C++17 plugin for C++17 standard (g++-6 or later)
.plugins[["cpp17"]] <- function() {
list(env = list(PKG_CXXFLAGS ="-std=c++17"))
if (getRversion() >= "3.4") # with recent R versions, R can decide
list(env = list(USE_CXX17 = "yes"))
else
list(env = list(PKG_CXXFLAGS ="-std=c++17"))
}

## built-in C++1z plugin for C++17 standard under development
Expand Down
8 changes: 7 additions & 1 deletion inst/NEWS.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@
\item Added sugar function \code{trimws} (Nathan Russell in \ghpr{680}
addressing \ghit{679}).
}
\item Changes in Rcpp Attributes:
\itemize{
\item The plugins for C++11, C++14, C++17 now set the values R 3.4.0 or
later expects; a plugin for C++98 was added (Dirk in \ghpr{684} addressing
\ghit{683}).
}
}
}

Expand All @@ -51,7 +57,7 @@
\item The \code{algorithm.h} file now accomodates the Intel compiler
(Dirk in \ghpr{643} and Dan in \ghpr{645} addressing issue \ghit{640}).
}
\item Changes in Rcpp Attributes
\item Changes in Rcpp Attributes:
\itemize{
\item The C++17 standard is supported with a new plugin (used eg for
\code{g++-6.2}).
Expand Down