Skip to content

Commit

Permalink
Condition undoing of Rmath prefixes on R < 4.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
eddelbuettel committed Dec 22, 2024
1 parent d5cfd78 commit 7b226dd
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
8 changes: 6 additions & 2 deletions inst/NEWS.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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{
Expand Down
22 changes: 18 additions & 4 deletions inst/include/Rcpp/sugar/undoRmath.h
Original file line number Diff line number Diff line change
@@ -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.
//
Expand All @@ -22,7 +20,22 @@
#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)

// Reverse-depends checks found rare cases where R_Version was not defined to we
// use the alternate of the predefined version (see Rversion.h for both)
#if (defined(R_Version) && R_VERSION < R_Version(4, 5, 0)) || (R_VERSION < 263424)

// undo some of the definitions in Rmath but only prior to R 4.5.0
#undef sign
#undef trunc
#undef rround
Expand Down Expand Up @@ -163,5 +176,6 @@
#undef tetragamma
#undef trigamma

#endif

#endif

0 comments on commit 7b226dd

Please sign in to comment.