source_file() will parse through file looking for functions tagged with
// [[ export() ]] and will compile the file and export those functions to
the R side.
source_file(file, includes = NULL, no_remap = TRUE, show = FALSE)
| file |
The C file to source. |
|---|---|
| includes |
Extra includes to add manually. By default, |
| no_remap |
Should |
| show |
Should the output of compiling the source code with |
A named list containing the functions specified for export.
tf <- tempfile(fileext = ".c") code <- " // [[ export() ]] SEXP fn(SEXP x) { return x; } " writeLines(code, tf) sourced <- source_file(tf) sourced$fn(1)#> [1] 1