For loop initial declaration used outside C99 mode during install #126

ghost opened this Issue Dec 18, 2012 · 4 comments


None yet

3 participants

ghost commented Dec 18, 2012

This may be an easy fix, but I am unsure what to do here. I am installing plyr (just as I have installed countless other packages), but I am running into an error with a variable declaration during the install. I know how to set gcc to c99 mode, but unsure how I would force the R installer to go through those processes.
If someone could provide some insight on this that would be great.

Here is the entire script of the install

sudo R CMD INSTALL plyr_1.8.tar.gz
installing to library ‘/Developer/lib/R/site-library’
installing source package ‘plyr’ ...
package ‘plyr’ successfully unpacked and MD5 sums checked

flag-sort -r gcc -I/Developer/Library/Frameworks/R.framework/Versions/2.15/Resources/include -DNDEBUG -I/Developer/include -fPIC -g -O2 -c loop-apply.c -o loop-apply.o
loop-apply.c: In function ‘loop_apply’:
loop-apply.c:15: error: ‘for’ loop initial declaration used outside C99 mode
make: *** [loop-apply.o] Error 1

ERROR: compilation failed for package ‘plyr’
removing ‘/Developer/lib/R/site-library/plyr’
restoring previous ‘/Developer/lib/R/site-library/plyr’

hadley commented Dec 30, 2012

Weird. Can you provide more os details?

wch commented Dec 30, 2012

You should be able to pass compile flags with a file called Makevars:

For example, you could do something like this:

$ cat ~/.R/Makevars
CFLAGS = -std=c99 -Wall -pedantic

For passing in compile flags for a single compilation you can set MAKEFLAGS.

MAKEFLAGS='CFLAGS=-std=c99 -Wall -pedantic' R CMD SHLIB src/*.c

According to Writing R Extensions:

R assumes a C99 compiler as from version 2.12.0, but if you want your package to be portable to earlier versions you should write in C90. (In practice C99 has been available on most platforms since ca 2007 but old versions of gcc were still in use for R 2.11.x.)

So @tyclark, using c99 should probably be set in your Makevars file. Just curious though - what platform are you using?

pnc commented Feb 27, 2013

FWIW, I just experienced this on OS X 10.7.5 with Xcode 4.5 installed.

eleos@Nebula ~$ uname -a                                                                                                                                                                                        
Darwin Nebula.local 11.4.2 Darwin Kernel Version 11.4.2: Thu Aug 23 16:25:48 PDT 2012; root:xnu-1699.32.7~1/RELEASE_X86_64 x86_64
eleos@Nebula ~$ gcc --version                                                                                                                                                 
i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO

Thanks for the Makevars fix, @wch. Worked perfectly.

hadley commented Jan 2, 2014

Uses Rcpp now, so definitely no longer a problem.

@hadley hadley closed this Jan 2, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment