[R-pkg-devel] Link compiled C object to internal package file

Iñaki Ucar |uc@r @end|ng |rom |edor@project@org
Wed Jun 19 17:21:37 CEST 2019

On Wed, 19 Jun 2019 at 16:47, mark padgham <mark.padgham using email.com> wrote:
> Yeah, but that would require completely rewriting the C code to accept a
> variable for something that is used hundreds of times as a simple macro.
> (Most of that C code is an old library bundled with the package, so not
> my work in that regard.) It would still be enormously easier to robustly
> provide a relative location within the compiled source object to direct
> it to the file ... but how?

I assume you have something like

#define MYMACRO "path/to/file"

and this MYMACRO is used here and there in the internal library.
Instead, you can set

#define MYMACRO getPath()

and this getPath function is defined somewhere and uses R's C API to
find that file and return the path (does someone know whether the
functionality of system.file() is directly accessible from C?).


More information about the R-package-devel mailing list