From 0315eaf21fd37944680cf470ca4d667e39b6754b Mon Sep 17 00:00:00 2001 From: Dirk Eddelbuettel Date: Sun, 4 Jan 2026 12:40:23 -0600 Subject: [PATCH] No longer require #ifdef for UNWIND_PROTECT, had been 'on' for long --- ChangeLog | 7 +++++++ DESCRIPTION | 4 ++-- inst/include/Rcpp/api/meat/Rcpp_eval.h | 25 ++----------------------- inst/include/Rcpp/r/headers.h | 6 +----- inst/include/RcppCommon.h | 7 ++----- inst/tinytest/cpp/stack.cpp | 11 ----------- inst/tinytest/test_interface.R | 16 +++++++++------- 7 files changed, 23 insertions(+), 53 deletions(-) diff --git a/ChangeLog b/ChangeLog index e4f6e5458..e0488af6b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -22,6 +22,13 @@ * inst/include/Rcpp/r_cast.h: Idem * src/attributes.cpp: Idem * src/barrier.cpp: Idem +2026-01-04 Dirk Eddelbuettel + + * inst/include/RcppCommon.h: No longer require RCPP_USING_UNWIND_PROTECT + * inst/include/Rcpp/r/headers.h: Idem + * inst/include/Rcpp/api/meat/Rcpp_eval.h: Idem + * inst/tinytest/cpp/stack.cpp: No longer test with RCPP_USING_UNWIND_PROTECT + * inst/tinytest/test_interface.R: Idem 2025-12-30 Dirk Eddelbuettel diff --git a/DESCRIPTION b/DESCRIPTION index 43cf1ced1..7076113bc 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: Rcpp Title: Seamless R and C++ Integration -Version: 1.1.0.13 -Date: 2025-12-23 +Version: 1.1.0.13.1 +Date: 2026-01-04 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/include/Rcpp/api/meat/Rcpp_eval.h b/inst/include/Rcpp/api/meat/Rcpp_eval.h index 177668694..340d2ac7a 100644 --- a/inst/include/Rcpp/api/meat/Rcpp_eval.h +++ b/inst/include/Rcpp/api/meat/Rcpp_eval.h @@ -1,4 +1,5 @@ -// Copyright (C) 2013 Romain Francois +// Copyright (C) 2013 - 2025 Romain Francois +// Copyright (C) 2026 Romain Francois and Dirk Eddelbuettel // // This file is part of Rcpp. // @@ -24,8 +25,6 @@ namespace Rcpp { namespace internal { -#ifdef RCPP_USING_UNWIND_PROTECT - struct EvalData { SEXP expr; SEXP env; @@ -42,36 +41,16 @@ inline SEXP Rcpp_eval_impl(SEXP expr, SEXP env) { // #nocov return Rcpp_fast_eval(expr, env); // #nocov } -#else // R < 3.5.0 - -// Fall back to Rf_eval() when the protect-unwind API is unavailable -inline SEXP Rcpp_eval_impl(SEXP expr, SEXP env) { - return ::Rf_eval(expr, env); -} - -#endif - }} // namespace Rcpp::internal namespace Rcpp { -#ifdef RCPP_USING_UNWIND_PROTECT - inline SEXP Rcpp_fast_eval(SEXP expr, SEXP env) { internal::EvalData data(expr, env); return unwindProtect(&internal::Rcpp_protected_eval, &data); } -#else - -inline SEXP Rcpp_fast_eval(SEXP expr, SEXP env) { - return Rcpp_eval(expr, env); -} - -#endif - - inline SEXP Rcpp_eval(SEXP expr, SEXP env) { // 'identity' function used to capture errors, interrupts diff --git a/inst/include/Rcpp/r/headers.h b/inst/include/Rcpp/r/headers.h index ab4f2e3ab..7bf972a3c 100644 --- a/inst/include/Rcpp/r/headers.h +++ b/inst/include/Rcpp/r/headers.h @@ -2,7 +2,7 @@ // // Copyright (C) 2008 - 2009 Dirk Eddelbuettel // Copyright (C) 2009 - 2024 Dirk Eddelbuettel and Romain Francois -// Copyright (C) 2025 Dirk Eddelbuettel, Romain Francois and Iñaki Ucar +// Copyright (C) 2025 - Dirk Eddelbuettel, Romain Francois and Iñaki Ucar // // This file is part of Rcpp. // @@ -101,8 +101,4 @@ # pragma pop_macro("makedev") #endif -#if !defined(RCPP_NO_UNWIND_PROTECT) -# define RCPP_USING_UNWIND_PROTECT -#endif - #endif /* RCPP__R__HEADERS__H */ diff --git a/inst/include/RcppCommon.h b/inst/include/RcppCommon.h index 18671e86f..ea23f5e82 100644 --- a/inst/include/RcppCommon.h +++ b/inst/include/RcppCommon.h @@ -1,10 +1,9 @@ -// // RcppCommon.h: Rcpp R/C++ interface class library -- common include and defines statements // // Copyright (C) 2008 - 2009 Dirk Eddelbuettel // Copyright (C) 2009 - 2020 Dirk Eddelbuettel and Romain Francois -// Copyright (C) 2021 - 2025 Dirk Eddelbuettel, Romain Francois and Iñaki Ucar +// Copyright (C) 2021 - 2026 Dirk Eddelbuettel, Romain Francois and Iñaki Ucar // // This file is part of Rcpp. // @@ -132,9 +131,7 @@ namespace Rcpp { #include #include -#ifdef RCPP_USING_UNWIND_PROTECT - #include -#endif +#include #include #include diff --git a/inst/tinytest/cpp/stack.cpp b/inst/tinytest/cpp/stack.cpp index 8bb7d52df..a4a5c86eb 100644 --- a/inst/tinytest/cpp/stack.cpp +++ b/inst/tinytest/cpp/stack.cpp @@ -65,10 +65,7 @@ SEXP maybeThrow(void* data) { SEXP testUnwindProtect(Environment indicator, bool fail) { unwindIndicator my_data(indicator); SEXP out = R_NilValue; - -#ifdef RCPP_USING_UNWIND_PROTECT out = Rcpp::unwindProtect(&maybeThrow, &fail); -#endif return out; } @@ -77,11 +74,7 @@ SEXP testUnwindProtect(Environment indicator, bool fail) { SEXP testUnwindProtectLambda(Environment indicator, bool fail) { unwindIndicator my_data(indicator); SEXP out = R_NilValue; - -#ifdef RCPP_USING_UNWIND_PROTECT out = Rcpp::unwindProtect([&] () { return maybeThrow(&fail); }); -#endif - return out; } @@ -100,10 +93,6 @@ struct FunctionObj { SEXP testUnwindProtectFunctionObject(Environment indicator, bool fail) { unwindIndicator my_data(indicator); SEXP out = R_NilValue; - -#ifdef RCPP_USING_UNWIND_PROTECT out = Rcpp::unwindProtect(FunctionObj(10, fail)); -#endif - return out; } diff --git a/inst/tinytest/test_interface.R b/inst/tinytest/test_interface.R index 22536db58..707571f27 100644 --- a/inst/tinytest/test_interface.R +++ b/inst/tinytest/test_interface.R @@ -81,16 +81,18 @@ expect_equal(result, 0L) ## Now test client package without protected evaluation unlink(user_name, recursive = TRUE) unlink(paste0(user_name, "-tests"), recursive = TRUE) -build_package(user_name, lib_path, config = "#define RCPP_NO_UNWIND_PROTECT") -result <- tools::testInstalledPackage(user_name, lib.loc = lib_path, types = "test") +## no longer supported in code +## build_package(user_name, lib_path, config = "#define RCPP_NO_UNWIND_PROTECT") -if (result) { - log <- file.path(paste0(user_name, "-tests"), "tests.Rout.fail") - cat(">> UNPROTECTED tests.Rout.fail", readLines(log), sep = "\n", file = stderr()) -} +## result <- tools::testInstalledPackage(user_name, lib.loc = lib_path, types = "test") -expect_equal(result, 0L) +## if (result) { +## log <- file.path(paste0(user_name, "-tests"), "tests.Rout.fail") +## cat(">> UNPROTECTED tests.Rout.fail", readLines(log), sep = "\n", file = stderr()) +## } + +## expect_equal(result, 0L) on.exit({ setwd(old_wd)