[R-pkg-devel] C++ library USING_R

Joseph Park Jo@ephP@rk @end|ng |rom IEEE@org
Wed Oct 14 21:56:40 CEST 2020


Dear R-devel,

The Writing R Extensions manual states:

6.14 Platform and version information
The header files define USING_R, which can be used to test if the code 
is indeed being used with R.

I suppose this only applies to building R itself?  Or, perhaps when Rcpp 
is used for the interface, or if one includes R headers explicitly.

I have a C++ library that is built with no R-dependencies, then wrapped 
with an Rcpp interface. This same library is wrapped with pybind11 in 
the Python world, and directly used in C++ applications.

How can the C++ library code "know" that it's R building the library? Is 
there a platform-independent environment variable or macro?

Thanks.



More information about the R-package-devel mailing list