[R] Cannot call R's ISNAN() from a C code in >1.7 versions.

Paul Y. Peng ypeng at math.mun.ca
Mon May 24 20:46:49 CEST 2004


Prof Brian Ripley wrote:
> First, there are no versions 1.7, 1.8 and 1.9.

Sorry for my misuse of the version numbers.

> Was your version of R compiled against MSVC++ 6.0?  The binary on CRAN was
> not, and binaries for different versions of R were compiled with different
> versions of MinGW.  The entry point isnan is part of the statically linked
> runtime on modern MinGW.

I used the binary on CRAN.

> MSVC++ 6.0 does supply _isnan (as it really should as it is part of the
> C99 ISO standard), and you need to link against it appropriately.  Hint:
> it may have an extra underline, since it seems it is known to C as _isnan.
> You may need to add
> 
> #undef ISNAN
> #define ISNAN(x) _isnan(x)

Many thanks for this suggestion. It works, as always. The extra
underline is required.

> We don't support adding extensions to R using a different compiler to the 
> one used to build R.  Changes already made for future releases of R will 
> make this less likely to work in R 2.0.x.

I wish that the R API entry points documented in "Writing R Extensions"
be supported in the future versions of R, because it will make programs
built with R more portable than directly using compiler-specific
functions, such as testing and generating the IEEE 754 special values.
The existing entry points have saved me trouble to chase these values
whenever I moved to an environment with a different compiler.

Thank you Brian for your help.
Paul.




More information about the R-help mailing list