diff --git a/ChangeLog b/ChangeLog index 1d7e8be83..f74e3af0d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2026-04-02 Dirk Eddelbuettel + + * inst/include/Rcpp/Function.h: Further refinement for 4.6.0 to not + require R_NamespaceRegistry, using R_getRegisteredNamespace() instead + 2026-04-01 Mattias Ellert * inst/discovery/cxx0x.R: Set execute permissions for script diff --git a/inst/include/Rcpp/Function.h b/inst/include/Rcpp/Function.h index 58f12d7e9..c98777bd3 100644 --- a/inst/include/Rcpp/Function.h +++ b/inst/include/Rcpp/Function.h @@ -71,13 +71,21 @@ namespace Rcpp{ Function_Impl(const std::string& name, const std::string& ns) { #if R_VERSION < R_Version(4,5,0) + // before R 4.5.0 we would use Rf_findVarInFrame Shield env(Rf_findVarInFrame(R_NamespaceRegistry, Rf_install(ns.c_str()))); if (env == R_UnboundValue) stop("there is no namespace called \"%s\"", ns); -#else +#elif R_VERSION < R_Version(4,6,0) || R_SVN_REVISION < 89746 + // during R 4.5.* and before final R 4.6.0 we could use R_getVarEx + // along with R_NamespaceRegistry but avoid R_UnboundValue Shield env(R_getVarEx(Rf_install(ns.c_str()), R_NamespaceRegistry, FALSE, R_NilValue)); if (env == R_NilValue) stop("there is no namespace called \"%s\"", ns); +#else + // late R 4.6.0 development got us R_getRegisteredNamespace + Shield env(R_getRegisteredNamespace(ns.c_str())); + if (env == R_NilValue) + stop("there is no namespace called \"%s\"", ns); #endif get_function(name, env); }