Skip to content

bnlearn package compilation failure on MacOSX

5 messages · Marco Scutari, Brian Ripley, Simon Urbanek

#
Hi all.

I've recently uploaded a package (bnlearn) to CRAN. It builds fine 
on both Linux (32 and 64 bit) and Windows, but fails on MacOSX ix86
because of C90 vs C99 issues:

http://www.r-project.org/nosvn/R.check/r-patched-macosx-ix86/bnlearn-00install.html

Since I've no MacOSX machine at hand, I would like to ask you:
why is C99 not the default for gcc on MacOSX ix86? Is it safe to 
force gcc to use C99 with either -std=c99 o -std=gnu99?

Thanks in advance.
#
You've got more serious problems than that: you cannot assume gcc.
For example on the SunPro compiler I got

cc -I/home/ripley/R/R-devel-SunPro/include 
-I/home/ripley/R/R-devel-SunPro/inclu
de  -I/usr/local/include    -Kpic  -xO5 -xc99 -xlibmil -nofstore -c 
mutual.infor
mation.c -o mutual.information.o
"mutual.information.c", line 34: member can not have variably modified 
type: n
"mutual.information.c", line 35: member can not have variably modified 
type: m
"mutual.information.c", line 41: cannot dereference non-pointer type
"mutual.information.c", line 52: cannot dereference non-pointer type
"mutual.information.c", line 52: cannot dereference non-pointer type
"mutual.information.c", line 53: cannot dereference non-pointer type
"mutual.information.c", line 53: cannot dereference non-pointer type
"mutual.information.c", line 54: cannot dereference non-pointer type
"mutual.information.c", line 54: cannot dereference non-pointer type
"mutual.information.c", line 60: warning: improper pointer/integer 
combination:
arg #5
"mutual.information.c", line 62: cannot recover from previous errors

Note that is in C99 mode, and under Linux.
On Thu, 4 Oct 2007, Marco Scutari wrote:

            

  
    
#
On Thu 04/10/07, Prof Brian Ripley wrote:
[snip]
Hmm. I'm able to reproduce at least some of these errors using
gcc in ansi mode:

[fizban@~/bnlearn/src]:gcc-4.2 -std=gnu99 -I/usr/share/R/include 
-I/usr/share/R/include -ansi -Wall -pedantic -std=c99 -fpic -g 
-O2 -c mutual.information.c -o mutual.information.o
mutual.information.c: In function 'mi': 
mutual.information.c:34: warning: a member of a structure or union
  cannot have a variably modified type
mutual.information.c:35: warning: a member of a structure or union
  cannot have a variably modified type

I'll work on that. On the other hand I'm still curious: why
r-patched-macosx-ix86 uses -std=gnu99 for the ppc arch but not 
for i386 one?
#
Marco,
On Oct 4, 2007, at 2:05 PM, Marco Scutari wrote:

            
It was not deliberate. The current R build (R 2.6.0) was modified to  
use -std=gnu99 in the CC section for both architectures instead of  
using CFLAGS, that should solve the problem. A work around for older  
R is to set PKG_CFLAGS=-std=gnu99 when installing bnlearn.

However, note that C99 compiler is not required for R so it may not  
be available. Since you don't really need any advanced functionality  
of C99, it may be a good idea to change it to a more portable C code.
Not in your package as cannot assume gcc in general, but temporarily  
for R 2.5.1 on OS X, yes.

Thanks,
Simon
#
On Thu 04/10/07, Simon Urbanek wrote:
Ok.
That's what I'm going to do; it's now on the top of my TODO list.
Thanks for the clarification.