[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6. The R API: entry points for C code

There are a large number of entry points in the R executable/DLL that can be called from C code (and some that can be called from FORTRAN code). Only those documented here are stable enough that they will only be changed with considerable notice.

The recommended procedure to use these is to include the header file `R.h' in your C code by

#include <R.h>

This will include several other header files from the directory `R_INCLUDE_DIR/R_ext', and there are other header files there that can be included too, but many of the features they contain should be regarded as undocumented and unstable.

An alternative is to include the header file `S.h', which may be useful when porting code from S. This includes rather less than `R.h', and has some extra compatibility definitions (for example the S_complex type from S).

The defines used for compatibility with S sometimes causes conflicts (notably with Windows headers), and the known problematic defines can be removed by defining STRICT_R_HEADERS.

Most of these header files, including all those included by `R.h', can be used from C++ code. Some others need to be included within an extern "C" declaration, and for clarity this is advisable for all R header files.

Note: Because R re-maps many of its external names to avoid clashes with user code, it is essential to include the appropriate header files when using these entry points.

This remapping can cause problems(70), and can be eliminated by defining R_NO_REMAP and prepending `Rf_' to all the function names used from `Rinternals.h' and `R_ext/Error.h'.

We can classify the entry points as


Entry points which are documented in this manual and declared in an installed header file. These can be used in distributed packages and will only be changed after deprecation.


Entry points declared in an installed header file that are exported on all R platforms but are not documented and subject to change without notice.


Entry points that are used when building R and exported on all R platforms but are not declared in the installed header files. Do not use these in distributed code.


Entry points that are where possible (Windows and some modern Unix-alike compilers/loaders when using R as a shared library) not exported.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated by root on April, 26 2012 using texi2html 1.76.