Skip to content

Commit feb4d7a

Browse files
authored
Merge pull request #684 from RcppCore/bugfix/issue683
Correcting CXX11 etc env vars for R 3.4.0 or later (closes #683)
2 parents e81493b + 486f285 commit feb4d7a

File tree

3 files changed

+35
-6
lines changed

3 files changed

+35
-6
lines changed

ChangeLog

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
2017-04-25 Dirk Eddelbuettel <[email protected]>
2+
3+
* R/Attributes.R (.plugins[["cpp11"]]): If R 3.4.0 or newer is used, set
4+
USE_CXX11 (instead of the older USE_CXX1X);
5+
(.plugins[["cpp14"]]): similarly updated for C++14
6+
(.plugins[["cpp17"]]): similarly updated for C++17
7+
(.plugins[["cpp98"]]): added
8+
19
2017-04-22 Nathan Russell <[email protected]>
210

311
* inst/include/Rcpp/sugar/functions/strings/trimws.h: Added sugar

R/Attributes.R

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

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

459-
# built-in C++11 plugin
459+
# built-in C++98 plugin
460+
.plugins[["cpp98"]] <- function() {
461+
if (getRversion() >= "3.4") # with recent R versions, R can decide
462+
list(env = list(USE_CXX98 = "yes"))
463+
else
464+
list(env = list(PKG_CXXFLAGS ="-std=c++98"))
465+
}
466+
# built-in C++11 plugin
460467
.plugins[["cpp11"]] <- function() {
461-
if (getRversion() >= "3.1") # with recent R versions, R can decide
468+
if (getRversion() >= "3.4") # with recent R versions, R can decide
469+
list(env = list(USE_CXX11 = "yes"))
470+
else if (getRversion() >= "3.1") # with recent R versions, R can decide
462471
list(env = list(USE_CXX1X = "yes"))
463472
else if (.Platform$OS.type == "windows")
464473
list(env = list(PKG_CXXFLAGS = "-std=c++0x"))
@@ -475,7 +484,10 @@ compileAttributes <- function(pkgdir = ".", verbose = getOption("verbose")) {
475484
## this is the default in g++-6.1 and later
476485
## per https://gcc.gnu.org/projects/cxx-status.html#cxx14
477486
.plugins[["cpp14"]] <- function() {
478-
list(env = list(PKG_CXXFLAGS ="-std=c++14"))
487+
if (getRversion() >= "3.4") # with recent R versions, R can decide
488+
list(env = list(USE_CXX14 = "yes"))
489+
else
490+
list(env = list(PKG_CXXFLAGS ="-std=c++14"))
479491
}
480492

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

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

491506
## built-in C++1z plugin for C++17 standard under development

inst/NEWS.Rd

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@
3030
\item Added sugar function \code{trimws} (Nathan Russell in \ghpr{680}
3131
addressing \ghit{679}).
3232
}
33+
\item Changes in Rcpp Attributes:
34+
\itemize{
35+
\item The plugins for C++11, C++14, C++17 now set the values R 3.4.0 or
36+
later expects; a plugin for C++98 was added (Dirk in \ghpr{684} addressing
37+
\ghit{683}).
38+
}
3339
}
3440
}
3541

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

0 commit comments

Comments
 (0)