Skip to content

Condition undoing of Rmath prefixes on R < 4.5.0 #1352

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

Closed
wants to merge 2 commits into from
Closed
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
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2024-12-22 Dirk Eddelbuettel <edd@debian.org>

* inst/include/Rcpp/sugar/undoRmath.h: Condition undefining of
non-prefixed Rmath functions in R < 4.5.0; redefine R_Version macro

2024-11-25 Dirk Eddelbuettel <edd@debian.org>

* DESCRIPTION (Version, Date): Roll micro version to 1.0.13.6
Expand Down
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
2 changes: 2 additions & 0 deletions inst/NEWS.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
\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 Down
17 changes: 13 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,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
Expand Down Expand Up @@ -163,5 +171,6 @@
#undef tetragamma
#undef trigamma

#endif

#endif