Re: [Rd] Detecting compilation under R

From: Barry Rowlingson <b.rowlingson_at_lancaster.ac.uk>
Date: Thu 14 Dec 2006 - 17:57:17 GMT

Prof Brian Ripley wrote:

> If *no* R.h is around: easy to solve.

  Have a dummy R.h somewhere?

> What is BUILD?

  Oh, pardon me for forgetting the arbitrary capitalisation of R CMD thingies. Can someone come up with a mnemonic for remembering that BATCH, COMPILE, SHLIB, INSTALL, LINK and REMOVE are all caps, that build, check, and config are lower case, and everything else has initial caps? Except for Sd2Rd. (Yes, R --help tells you).

> You've clipped it from my previous mail, with no indication. As the
> posting guide points out, this is reprehensible.

  This bit?

#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

  USING_R is only useful here if you can make #include <R.h> not include the official R.h file and not give a 'file not found' error message. I cant see how to do this without requiring either a dummy R.h file somewhere or options on the C command line. This would then be better done with cc -DR_CODE and then use #ifdef R_CODE to include R.h. Then USING_R is meaningful.

  Here's what I'd like to do. Give someone a file 'simple.c' and say:

  "Compile it with 'cc -o simple simple.c -lgsl' and then run from the command line, or do 'R CMD SHLIB simple.c', then do a dyn.load and a .C() call'."

  if "R CMD SHLIB" and "R CMD build" set a preprocessor flag then this could be done. You could even have -DRSHLIB and -DRbuild on the command line to give it a bit more intelligence.

  My behaviour may be reprehensible but sometimes your responses seem cryptic to the point of incomprehensible.

Barry



R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Fri Dec 15 21:19:53 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 Fri 15 Dec 2006 - 11:31:00 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.