[Rd] Compatibility of external C code across platforms
Murray Efford
murray.efford at otago.ac.nz
Sat Sep 26 12:25:25 CEST 2009
Thank you. I'm much clearer on this. I now notice that the messages from gcc distinguish breaches of ISO C and ISO C90, and can see the significance. My gcc versions were the same - the different behaviour is likely to be explained by the --std flag. And it looks like I have to re-write a lot of C to eliminate nesting of functions. Point taken about HTML.
Murray Efford
________________________________________
From: Prof Brian Ripley [ripley at stats.ox.ac.uk]
Sent: Saturday, 26 September 2009 9:40 p.m.
To: Murray Efford
Cc: r-devel at lists.R-project.org
Subject: Re: [Rd] Compatibility of external C code across platforms
On Sat, 26 Sep 2009, Murray Efford wrote:
> A package I have written makes considerable use of external C code.
> There appear to be no problems building a Windows binary with the
> GNU C compiler, but now I would like to make the package available
> for other platforms. A stringent check of the code with the gcc
> options '-Wall -pedantic' flags many nested functions and
> variable-length arrays that are not allowed in ISO C. Is it
> essential that distributed C source code for R packages conforms to
> ISO C in this respect? I'm working in Windows XP with R2.9.2 and
> Rtools 2.9.
Yes, it is essential. R does not assume gcc, and it does not even
assume gcc 4.x (and people are still using gcc 3.x on some platforms,
e.g. the sunfreeware R builds). This is why we publish test result on
CRAN for a completely different compiler (from SunPro).
However, if is not clear which standard you mean by 'ISO C': assuming
C99 is fairly safe, but GNU extensions from C99 are not -- nested
functions are one such.
> [Incidentally, when I use a makevars.win file to include these gcc
> options in Rcmd build etc. the problem with variable-length arrays
> is not flagged; maybe my command-line gcc is a different version
> from that in Rtools]
Well, you (and only you) can easily check that for yourself, but the
other flags also matter, especially --std. Because it has been needed
for the use of the MinGW headers, R on Windows is built with
--std=gnu99. (Linux headers have a similar problem: using --std=c99
disables some features we test for in configure and wish to use -- and
there are OS features, not language extensions.)
>
> Murray Efford
> University of Otago
> Dunedin, New Zealand
> murray.efford at otago.ac.nz<mailto:murray.efford at otago.ac.nz>
>
> [[alternative HTML version deleted]]
Please note what the posting guide has to say about that.
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-devel
mailing list