From 58c22d205f5749c11c81814824e5bc2491486fd0 Mon Sep 17 00:00:00 2001 From: Dirk Eddelbuettel Date: Sun, 22 Dec 2024 17:05:12 -0600 Subject: [PATCH] Condition undoing of Rmath prefixes on R < 4.5.0 --- DESCRIPTION | 4 ++-- inst/NEWS.Rd | 8 ++++++-- inst/include/Rcpp/sugar/undoRmath.h | 17 +++++++++++++---- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 1eec8dc2d..8e70f1cbb 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: Rcpp Title: Seamless R and C++ Integration -Version: 1.0.13.6 -Date: 2024-11-25 +Version: 1.0.13.6.1 +Date: 2024-12-21 Authors@R: c(person("Dirk", "Eddelbuettel", role = c("aut", "cre"), email = "edd@debian.org", comment = c(ORCID = "0000-0001-6419-907X")), person("Romain", "Francois", role = "aut", diff --git a/inst/NEWS.Rd b/inst/NEWS.Rd index a88e87e4f..95fd9305d 100644 --- a/inst/NEWS.Rd +++ b/inst/NEWS.Rd @@ -9,14 +9,16 @@ \itemize{ \item Support for user-defined databases has been removed (Kevin in \ghpr{1314} fixing \ghit{1313}) - \item The \code{SET_TYPEOF} function and macro is no longer used (Kevin in - \ghpr{1315} fixing \ghit{1312}) + \item The \code{SET_TYPEOF} function and macro is no longer used (Kevin + in \ghpr{1315} fixing \ghit{1312}) \item An errorneous cast to \code{int} affecting large return object has been removed (Dirk in \ghpr{1335} fixing \ghpr{1334}) \item Compilation on DragonFlyBSD is now supported (Gábor Csárdi in \ghpr{1338}) \item Use read-only \code{VECTOR_PTR} and \code{STRING_PTR} only with with R 4.5.0 or later (Kevin in \ghpr{1342} fixing \ghit{1341}) + \item As R 4.5.0 or later prefix math functions, make undefine in Rcpp + Sugar version dependent (Dirk in \ghpr{1352} fixing \ghit{1351}) } \item Changes in Rcpp Attributes: \itemize{ @@ -30,6 +32,8 @@ \item Authors@R is now used in DESCRIPTION as mandated by CRAN, the \code{Rcpp.package.skeleton()} function also creates it (Dirk in \ghpr{1325} and \ghpr{1327}) + \item A single datetime format test has been adjusted to match a change + in R-devel (Dirk in \ghpr{1348} fixing \ghit{1347}) } \item Changes in Rcpp Documentation: \itemize{ diff --git a/inst/include/Rcpp/sugar/undoRmath.h b/inst/include/Rcpp/sugar/undoRmath.h index c718b724a..2288ad767 100644 --- a/inst/include/Rcpp/sugar/undoRmath.h +++ b/inst/include/Rcpp/sugar/undoRmath.h @@ -1,8 +1,6 @@ -// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*- -// // undoRmath.h: Rcpp R/C++ interface class library -- undo the macros set by Rmath.h // -// Copyright (C) 2010 - 2011 Dirk Eddelbuettel and Romain Francois +// Copyright (C) 2010 - 2024 Dirk Eddelbuettel and Romain Francois // // This file is part of Rcpp. // @@ -22,7 +20,17 @@ #ifndef RCPP_SUGAR_UNDORMATH_H #define RCPP_SUGAR_UNDORMATH_H -// undo some of the mess of Rmath +// Reverse-depends checks found rare cases where R_Version would not evaluate +// So here we, if needed, we first undefine ... +#ifdef R_Version +#undef R_Version +#endif +// ... and then repeat the definition from Rversion.h +#define R_Version(v,p,s) (((v) * 65536) + ((p) * 256) + (s)) + +// Undo some of the definitions in Rmath -- but only prior to R 4.5.0 +#if R_VERSION < R_Version(4,5,0) + #undef sign #undef trunc #undef rround @@ -163,5 +171,6 @@ #undef tetragamma #undef trigamma +#endif #endif