[R-pkg-devel] Compiling error with the new R.h header (R-devel 3.3.0 for Windows) when using the C++ function isnan() of <math.h>

Antonio Canale antonio.canale at unito.it
Wed Apr 20 14:28:20 CEST 2016

Dear all,

my problem is related to the new version of my msBP package but it
actually applies also to the current version uploaded on CRAN

It turns out that the package cannot be compiled under the new R-devel
for windows.

The problem is related to the isnan() function of <math.h> library of
C++ which I call twice in one of my C++ scripts.

Consider the function below as MWE

extern "C"{
void gibbs(double *A)
if(isnan(A[i]) || (A[i]<=0))
{ do stuff }

Precisely, the error that I get is reported at

I've have found in the R-devel blog and check myself that from R
version 3.3.0 the header  file R.h is changed. In particular it is now
going to include the C++ versions of system header ‘<cmath>’ rather
than the legacy header ‘<math.h> which seems to be the source of my

However I cannot understand why it causes the error and in particular
why it is happening *only under windows* and not under other OS. I've
check my new package both in OS X and Ubuntu (with R-devel) and
everything is OK. It also compiles fine in Windows under R.3.2.5.

Thanks for your help.


Antonio Canale
University of Turin and
Collegio Carlo Alberto

More information about the R-package-devel mailing list