Obtain a Description of one or more Native (C/Fortran) Symbols
This finds and returns a description of one or more dynamically loaded
or ‘exported’ built-in native symbols. For each name, it
returns information about the name of the symbol, the library in which
it is located and, if available, the number of arguments it expects
and by which interface it should be called (i.e
.External). Additionally, it returns the address of the
symbol and this can be passed to other C routines. Specifically, this
provides a way to explicitly share symbols between different
dynamically loaded package libraries. Also, it provides a way to
query where symbols were resolved, and aids diagnosing strange
behavior associated with dynamic resolution.
the name(s) of the native symbol(s).
an optional argument that specifies to which
DLL to restrict the search for this symbol. If this is
a logical value which controls how the result is
returned if the function is called with the name of a single symbol.
a logical value indicating whether, if
This uses the same mechanism for resolving symbols as is used
in all the native interfaces (
If the symbol has been explicitly registered by the DLL
in which it is contained, information about the number of arguments
and the interface by which it should be called will be returned.
Otherwise, a generic native symbol object is returned.
Generally, a list of
NativeSymbolInfo elements whose elements
can be indexed by the elements of
name in the call. Each
NativeSymbolInfo object is a list containing the following
the name of the symbol, as given by the
a list containing 3 elements:
If the routine was explicitly registered by the dynamically loaded library, the list contains a fourth field
the number of arguments that should be passed in a call to this routine.
Additionally, the list will have an additional class,
ExternalRoutine corresponding to the R interface by which it
should be invoked.
If any of the symbols is not found, an error is raised.
name contains only one symbol name and
TRUE, then the single
NativeSymbolInfo is returned
rather than the list containing that one element.
One motivation for accessing this reflectance information is to be
able to pass native routines to C routines as function pointers in C.
This allows us to treat native routines and R functions in a similar
manner, such as when passing an R function to C code that makes
callbacks to that function at different points in its computation
nls). Additionally, we can resolve the symbol
just once and avoid resolving it repeatedly or using the internal
Duncan Temple Lang
For information about registering native routines, see “In Search of C/C++ & FORTRAN Routines”, R-News, volume 1, number 3, 2001, p20–23 (https://www.r-project.org/doc/Rnews/Rnews_2001-3.pdf).