Modern Interfaces to C/C++ code
Functions to pass Robjects to compiled C/C++ code that has been loaded into R.
.Call(.NAME, ..., PACKAGE) .External(.NAME, ..., PACKAGE)
- a character string giving the name of a C function,
or an object of class
"NativeSymbol"referring to such a name.
- arguments to be passed to the compiled code. Up to 65 for
- if supplied, confine the search for a character string
.NAMEto the DLL given by this argument (plus the conventional extension, .so, .dll, ...).
This argument follows
...and so its name cannot be abbreviated.
This is intended to add safety for packages, which can ensure by using this argument that no other package can override their external symbols, and also speeds up the search (see Note).
The functions are used to call compiled code which makes use of internal Robjects, passing the arguments to the code as a sequence of Robjects. They assume C calling conventions, so can usually also be used of C++ code.
For details about how to write code to use with these functions see
the chapter on
.External allows for a
variable number of arguments.
These functions are primitive, and
.NAME is always
matched to the first argument supplied (which should not be named).
For clarity, avoid using names in the arguments passed to
that match or partially match
- An Robject constructed in the compiled code.
If one of these functions is to be used frequently, do specify
PACKAGE (to confine the search to a single DLL) or pass
.NAME as one of the native symbol objects. Searching for
symbols can take a long time, especially when many namespaces are loaded.
You may see
PACKAGE = "base" for symbols linked into R. Do
not use this in your own code: such symbols are not part of the API
and may be changed without warning.
PACKAGE = "" used to be accepted (but was undocumented): it is
now an error.
Header files for external code
Writing code for use with these functions will need to use internal R structures defined in Rinternals.h and/or the macros in Rdefines.h.
Chambers, J. M. (1998)
Programming with Data. A Guide to the S Language.