From roebuck at mdanderson.org  Wed Dec 20 00:12:25 2006
From: roebuck at mdanderson.org (Paul Roebuck)
Date: Tue, 19 Dec 2006 17:12:25 -0600 (CST)
Subject: [Rd] Detecting compilation under R
In-Reply-To: <Pine.LNX.4.64.0612141716400.3286@gannet.stats.ox.ac.uk>
References: <45816A65.8000802@lancaster.ac.uk>
	<Pine.LNX.4.64.0612141618580.29210@gannet.stats.ox.ac.uk>
	<45818652.7050102@lancaster.ac.uk>
	<Pine.LNX.4.64.0612141716400.3286@gannet.stats.ox.ac.uk>
Message-ID: <Pine.OSF.4.58.0612191624470.290351@wotan.mdacc.tmc.edu>

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);
#else
    #include <gsl_random.h>
    x = gsl_runif(0.0,1.0);
#endif

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)



[Rd] Detecting compilation under R
Paul Roebuck