[ top | up ]

## Foreign Function Interface

### Syntax

    .C(name, ..., NAOK=FALSE)
    .Fortran(name, ..., NAOK=FALSE)

    dyn.load(libname)

### Arguments

`name` | a character string giving the name of a C function or Fortran subroutine.
`...` | arguments to be passed to the foreign function.
`NAOK` | if `TRUE` then any `NA` values in the arguments are passed on to the foreign function. If `FALSE`, the presence of `NA` values is regarded as an error.
`libname` | a character string giving the pathname to a DLL.

### Description

The functions `.C` and `.Fortran` can be used to make calls to C and Fortran code.

`dyn.load` links the specified shared library to the executing R image. Calls to `.C` and `.Fortran` can then be used to execute C functions or Fortran subroutines contained in the library.

The creation of shared libraries the runtime linking of them into executing programs is very platform dependent. In recent years there has been some simplification in the process because the C subroutine call `dlopen` has become the standard for doing this under Unix. `dyn.load` uses the `dlopen` mechanism and should work on all platforms which support it.

The original code for loading DLLs in UNIX was provided by Heiner Schwarte.