Issue compiling trunk in Mac OS X

Hi,

I’ve recently updated my version of ROOT to the latest trunk (hadn’t done so in a few weeks) and came across the following error:

[code]bin/rmkdepend -R -fcint/cint/src/g__cfunc.d -Y -w 1000 – -m64 -pipe -W -Wall -fsigned-char -fno-common -Iinclude -DG__REGEXP -DG__UNIX -DG__SHAREDLIB -DG__ROOT -DG__REDIRECTIO -DG__OSFDLL -DG__STD_EXCEPTION -DG__HAVE_CONFIG -DG__NOMAKEINFO -DG__CINTBODY -Icint/cint/inc -I/Applications/OpenSource/WorkingCopies/root/cint/cint/inc -I/Applications/OpenSource/WorkingCopies/root/cint/cint/src -I/Applications/OpenSource/WorkingCopies/root/cint/cint/src/dict -pthread -I. – /Applications/OpenSource/WorkingCopies/root/cint/cint/src/g__cfunc.c
clang -O2 -m64 -pipe -W -Wall -fsigned-char -fno-common -Iinclude -DG__REGEXP -DG__UNIX -DG__SHAREDLIB -DG__ROOT -DG__REDIRECTIO -DG__OSFDLL -DG__STD_EXCEPTION -DG__HAVE_CONFIG -DG__NOMAKEINFO -DG__CINTBODY -Icint/cint/inc -I/Applications/OpenSource/WorkingCopies/root/cint/cint/inc -I/Applications/OpenSource/WorkingCopies/root/cint/cint/src -I/Applications/OpenSource/WorkingCopies/root/cint/cint/src/dict -pthread -I. -o cint/cint/src/g__cfunc.o -c /Applications/OpenSource/WorkingCopies/root/cint/cint/src/g__cfunc.c
In file included from /Applications/OpenSource/WorkingCopies/root/cint/cint/src/g__cfunc.c:38:
In file included from /Applications/OpenSource/WorkingCopies/root/cint/cint/src/common.h:43:
In file included from include/G__ci.h:1621:
include/G__ci_fproto.h:19:19: error: token is not a valid binary operator in a preprocessor subexpression

if __has_warning("-Wreturn-type-c-linkage")

 ~~~~~~~~~~~~~^

1 error generated.
make: *** [cint/cint/src/g__cfunc.o] Error 1
[/code]

Even “make distclean” and re-compiling didn’t solve the problem. Upon investigation, it seems that the expression is not recognized with the official version of llvm installed, i.e.

Apple clang version 3.0 (tags/Apple/clang-211.12) (based on LLVM 3.0svn)

Looking at the specified file, I see there are two versions, one of which has an extra check (the one from the cint directory) on __has_warning. Once I remove it everything compiles fine.

[code]pb-d-128-141-137-44:root karolos$ svn info
Path: .
URL: https://root.cern.ch/svn/root/trunk
Repository Root: https://root.cern.ch/svn/root
Repository UUID: 27541ba8-7e3a-0410-8455-c3a389f83636
Revision: 44094
Node Kind: directory
Schedule: normal
Last Changed Author: axel
Last Changed Rev: 44094
Last Changed Date: 2012-05-03 16:50:12 +0200 (Thu, 03 May 2012)

0 conflicts are found.
pb-d-128-141-137-44:root karolos$ diff ./cint/cint/inc/G__ci_fproto.h ./include/G__ci_fproto.h
18,25d17
< #if defined(clang)
< # if __has_warning("-Wreturn-type-c-linkage")
< // ‘G__getfunction’ has C-linkage specified, but returns
< // user-defined type ‘G__value’ which is incompatible with C
< # pragma clang diagnostic ignored “-Wreturn-type-c-linkage”
< # endif
< #endif
<
pb-d-128-141-137-44:root karolos$
[/code]

Could it be that the __has_warning preprocessor subexpression is not understood by the compiler? I didn’t investigate this further but wanted to bring this to your attention.

Is there a fix, such as putting a guard enabling the expression only when the required version of clang is installed? Alternatively, do you have another suggestion?

Cheers,
Karolos

Hi,

if you are using Lion 10.7.3 please install the latest Xcode + the command line tools (special install via Xcode Preferences panel). This should give the most recent clang:

(proof) [164] clang++ -v
Apple clang version 3.1 (tags/Apple/clang-318.0.58) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin11.3.0
Thread model: posix

Cheers, Fons.

Hi Fons,

Indeed, thank you very much for mentioning this. I didn’t realize the move to an “add-on” type of installer in the Preferences panel.

Cheers,
Karolos