This page gives guidance on porting R code and C packages to work with CXXR, and on some coding practices that may affect the portability of CXXR to different platforms.

R Code

In general, if R code behaves differently under CXXR and under the standard C-based R (in the release of CR on which this release of CXXR is based), then that is a bug in CXXR: please report it. However, differences in timing and in space consumption are to be expected. The following differences are intentional:

Also, there may be differences in the behaviour of R functions which probe into the implementation of the interpreter. In particular:

Moreover, while CXXR is at an alpha development stage, internal logic errors (i.e. errors due to bugs in the interpreter rather than to bugs in the R code it is interpreting) will sometimes cause the interpreter itself to terminate, even in circumstances where CR would manage to recover to the top-level prompt. This is intentional in order to 'preserve the scene of crime' for debugging. Also, typing Control-C will currently cause the CXXR interpreter to terminate, rather than returning to the top-level prompt: if this is a nuisance, change the setting of R_SignalHandlers at around line 809 in main.cpp from 0 to 1, and rebuild.

C Code

Latent memory protection bugs

C and C++ code that appears to work under CR can often contain latent memory protection bugs that will only manifest themselves when a garbage collection occurs at a particular point in execution. Such bugs are very likely to become hard failures under CXXR: refer to this page for advice on diagnosing such bugs.

Mandatory changes for code using R.h or S.h:

Mandatory changes for code using Rinternals.h:

The following changes are required in addition to those listed above for code using .h or S.h:

Suggested changes:

FORTRAN Code

Mandatory changes:

C++ Code

It is a central intention of CXXR to make a wide range of functionality, over and above that offered by CR, available to C++ packages via the $(R_HOME)/include/CXXR API. However, package authors should be aware that this API is currently in a state of considerable flux from release to release. If you are exploiting this API please let me know, so that I can take your requirements on board, and forewarn you of upcoming changes.

Porting to Other Platforms

The following are areas where portability has been traded for efficiency, simplicity and/or clarity in new code generated for CXXR. There may be other unportabilities in code inherited from CR.