Re: [Rd] Detecting compilation under R

From: Paul Roebuck <>
Date: Tue 19 Dec 2006 - 23:12:25 GMT

On Thu, 14 Dec 2006, Prof Brian Ripley wrote:

> On Thu, 14 Dec 2006, Barry Rowlingson wrote:
> [Silently discarding the answer to his question, and breaching
> 'fair use' copyright provisions.]
> >> So the problem is that you needed rather
> >>
> >> #include <R.h>
> >> #ifdef USING_R
> >> x = rand_unif(0.0,1.0);
> >> #else
> >> #include <gsl_random.h>
> >> x = gsl_runif(0.0,1.0);
> >> #endif
> >>
> >> since if R.h is not around, the include will not include it.
> > If R.h is not around, the preprocessor will throw a tantrum:
> If *no* R.h is around: easy to solve.
> > cc -c -o simple.o simple.c
> > simple.c:2:15: error: R.h: No such file or directory
> >
> [SNIP - PLR]
Never saw the reply to Barry's question. His quoting methodology notwithstanding, I don't see the answer plainly either.

When Prof. Ripley says above - "easy to solve", is the implication that R installation become prerequisite or creating a fake "R.h"?

Would have thought it easiest to solve by adding -DUSING_R to Makevar's PKG_CPPFLAGS with the code restructured as below.

#ifdef USING_R

    #include <R.h>
    x = rand_unif(0.0,1.0);

    #include <gsl_random.h>
    x = gsl_runif(0.0,1.0);

Barry's suggestion to eliminate this step by having any R-based compile process identify itself (although a single preprocessor define is sufficient) would be a nice addition, simplifying life when a source file can be used with R or standalone.

SIGSIG -- signature too long (core dumped) mailing list Received on Wed Dec 20 19:04:56 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 20 Dec 2006 - 08:31:04 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.