Skip to content

Remove non-API usage of R_NamespaceRegistry#488

Merged
DavisVaughan merged 5 commits intomainfrom
feature/non-api
Apr 3, 2026
Merged

Remove non-API usage of R_NamespaceRegistry#488
DavisVaughan merged 5 commits intomainfrom
feature/non-api

Conversation

@DavisVaughan
Copy link
Copy Markdown
Member

@DavisVaughan DavisVaughan commented Apr 2, 2026

Closes #487

Replaced with the new R_getRegisteredNamespace() on r-devel, and our own polyfill for that.


Plus two other minor things:

  • Fixed a bug with CPP11_USE_FMT where the input was not being correctly wrapped in fmt::runtime() (related to the default C++ compiler for R 4.6 being C++20)
  • Define RCPP_NO_R_HEADERS_CHECK before all #include <Rcpp.h> usage

We got it through `cpp11/protect.hpp`, but we should not rely on that
…mat()`

In fmt, there is a `FMT_CONSTEVAL` macro that resolves to `consteval` on "new enough" C++ (otherwise it doesn't do anything). For R 4.6+, the default C++ used is finally "new enough" (`__cplusplus > 201703L`).

This causes all `fmt::format()` calls to require a constant expression for `const char*` and `std::string&` input, which we are not currently doing via `fmt_arg`.

We have a runtime provided string, which must now be wrapped in `fmt::runtime()`, which is what we should have been doing all along.
Throwing an informative (and tested!) error when we can't find the package namespace
`#include <cpp11/R.hpp>` sets everything up the right way, and otherwise we get a warning from Rcpp which doesn't seem to end up being relevant for this use case
To avoid triggering a NOTE about usage of `Rf_findVarInFrame3()` on R 4.5, where technically we had the tools to avoid that
@DavisVaughan DavisVaughan merged commit 8bcc0f7 into main Apr 3, 2026
16 checks passed
@DavisVaughan DavisVaughan deleted the feature/non-api branch April 3, 2026 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Found non-API call to R: ‘R_NamespaceRegistry’

1 participant