[R-pkg-devel] "Writing R Extensions" manual needs update [was: Error handling in C code]
Agner Fog
@gner @end|ng |rom @gner@org
Mon Jun 24 08:25:10 CEST 2024
Jarrod Hadfield wrote:
> Using Rf_error() rather than error() fixed the problem. Not sure why the problem was only flagged on Debian, but it
> seems to have been triggered by R_NO_REMAP being defined (which will be default in R 4.5.0).
I had the same problem. A lot of functions in my package 'BiasedUrn' had
to be changed to the Rf_ prefix names. It took me a long time to figure
out because I couldn't find proper documentation anywhere.
Apparently, the remapped function names can no longer be used. The
consequences of this change are far-reaching: /all /existing packages
containing C++ code must be modified to use the Rf_ function names for
/all /R API function calls.
This change is not properly documented. The "Writing R Extensions"
manual still lists the remapped function names without Rf_ prefix. This
manual needs to be updated to replace all remapped function names with
the Rf_ prefix names. I also think that it needs to add instructions on
how to fix legacy C++ code, including a list of the function names that
need to be changed. I cannot see where the change in R_NO_REMAP is
documented.
I don't know why R_NO_REMAP is currently defined in Debian but not in
Windows, but the consequence is that the "Writing R Extensions" manual
must be updated now, and not wait for R version 4.5.0.
I think there should be a way to enable the remapped function names for
the sake of compatibility with legacy code. What should we do with old
packages where the maintainer is no longer contactable or is somebody
less competent than the original programmer?
Does it work to #undef R_NO_REMAP before #include <R.h> ?
Let me suggest a simple solution: Define a preprocessing macro
R_FORCE_REMAP which can override R_NO_REMAP. Legacy C++ code can then be
fixed by adding a Makevars file with -DR_FORCE_REMAP
You may also reconsider the decision to add R_NO_REMAP as standard.
I have written to the maintainers and asked them to change the "Writing
R Extensions" manual, but got no reponse.
- Agner
[[alternative HTML version deleted]]
More information about the R-package-devel
mailing list