ROOT lib from command line (mathcalls.h and TMath.h errors)

Hi,
i need to compile program using ROOT libraries, but calling them via (Linux) command line and not entering the ROOT interactive session. I’m using this compile options (only those regarding ROOT):

$(root-config --cflags) $(root-config --glibs) -Wall -O -fPIC

However i’m getting this errors during the compile phase dealing with mathcalls.h and TMath.h.

In file included from /usr/include/math.h:70,
from /afs/cern.ch/user/c/calviani/root/include/TMath.h:525,
from /afs/cern.ch/user/c/calviani/root/include/TString.h:32,
from /afs/cern.ch/user/c/calviani/root/include/TCollection.h:34,
from /afs/cern.ch/user/c/calviani/root/include/TSeqCollection.h:26,
from /afs/cern.ch/user/c/calviani/root/include/TList.h:26,
from /afs/cern.ch/user/c/calviani/root/include/TNamed.h:29,
from /afs/cern.ch/user/c/calviani/root/include/TTree.h:30,
from marco_new_single.c:31:
/usr/include/bits/mathcalls.h:110: error: conflicting declaration ‘double (logfunc)(double)’
/usr/include/shift/log.h:20: error: ‘logfunc’ has a previous declaration as void (*logfunc)(int, char*, ...)' /usr/include/bits/mathcalls.h:110: error: type mismatch with previous external decl ofdouble (logfunc)(double)’
/usr/include/shift/log.h:20: error: previous external decl of void (*logfunc)(int, char*, ...)' /usr/include/bits/mathcalls.h:110: error: conflicting declaration 'double (*logfunc)(double)' /usr/include/shift/log.h:20: error: 'logfunc' has a previous declaration asvoid (logfunc)(int, char, …)‘
In file included from /usr/include/math.h:70,
from /afs/cern.ch/user/c/calviani/root/include/TMath.h:525,
from /afs/cern.ch/user/c/calviani/root/include/TString.h:32,
from /afs/cern.ch/user/c/calviani/root/include/TCollection.h:34,
from /afs/cern.ch/user/c/calviani/root/include/TSeqCollection.h:26,
from /afs/cern.ch/user/c/calviani/root/include/TList.h:26,
from /afs/cern.ch/user/c/calviani/root/include/TNamed.h:29,
from /afs/cern.ch/user/c/calviani/root/include/TTree.h:30,
from marco_new_single.c:31:
/usr/include/bits/mathcalls.h:110:1: pasting “" and “(” does not give a valid preprocessing token
/usr/include/bits/mathcalls.h:110: error: cannot convert void (*)(int, char*, ...)' todouble’ in initialization
/usr/include/bits/mathcalls.h:110: error: expected ,' or;’ before ‘(’ token
In file included from /usr/include/math.h:93,
from /afs/cern.ch/user/c/calviani/root/include/TMath.h:525,
from /afs/cern.ch/user/c/calviani/root/include/TString.h:32,
from /afs/cern.ch/user/c/calviani/root/include/TCollection.h:34,
from /afs/cern.ch/user/c/calviani/root/include/TSeqCollection.h:26,
from /afs/cern.ch/user/c/calviani/root/include/TList.h:26,
from /afs/cern.ch/user/c/calviani/root/include/TNamed.h:29,
from /afs/cern.ch/user/c/calviani/root/include/TTree.h:30,
from marco_new_single.c:31:
/usr/include/bits/mathcalls.h:110:1: pasting “)” and “f” does not give a valid preprocessing token
In file included from /usr/include/math.h:93,
from /afs/cern.ch/user/c/calviani/root/include/TMath.h:525,
from /afs/cern.ch/user/c/calviani/root/include/TString.h:32,
from /afs/cern.ch/user/c/calviani/root/include/TCollection.h:34,
from /afs/cern.ch/user/c/calviani/root/include/TSeqCollection.h:26,
from /afs/cern.ch/user/c/calviani/root/include/TList.h:26,
from /afs/cern.ch/user/c/calviani/root/include/TNamed.h:29,
from /afs/cern.ch/user/c/calviani/root/include/TTree.h:30,
from marco_new_single.c:31:
/usr/include/bits/mathcalls.h:110: error: expected initializer before “f”
/usr/include/bits/mathcalls.h:110:1: pasting "
” and “(” does not give a valid preprocessing token
/usr/include/bits/mathcalls.h:110: error: conflicting declaration ‘float '
/usr/include/bits/mathcalls.h:110: error: '
’ has a previous declaration as double __' /usr/include/bits/mathcalls.h:110: error: type mismatch with previous external decl offloat __’
/usr/include/bits/mathcalls.h:110: error: previous external decl of double __' /usr/include/bits/mathcalls.h:110: error: declaration offloat __’
/usr/include/bits/mathcalls.h:110: error: conflicts with previous declaration double __' /usr/include/bits/mathcalls.h:110:1: pasting ")" and "f" does not give a valid preprocessing token /usr/include/bits/mathcalls.h:110: error: cannot convertvoid (
)(int, char
, …)’ to float' in initialization /usr/include/bits/mathcalls.h:110: error: expected,’ or ;' before "f" In file included from /usr/include/math.h:114, from /afs/cern.ch/user/c/calviani/root/include/TMath.h:525, from /afs/cern.ch/user/c/calviani/root/include/TString.h:32, from /afs/cern.ch/user/c/calviani/root/include/TCollection.h:34, from /afs/cern.ch/user/c/calviani/root/include/TSeqCollection.h:26, from /afs/cern.ch/user/c/calviani/root/include/TList.h:26, from /afs/cern.ch/user/c/calviani/root/include/TNamed.h:29, from /afs/cern.ch/user/c/calviani/root/include/TTree.h:30, from marco_new_single.c:31: /usr/include/bits/mathcalls.h:110:1: pasting ")" and "l" does not give a valid preprocessing token In file included from /usr/include/math.h:114, from /afs/cern.ch/user/c/calviani/root/include/TMath.h:525, from /afs/cern.ch/user/c/calviani/root/include/TString.h:32, from /afs/cern.ch/user/c/calviani/root/include/TCollection.h:34, from /afs/cern.ch/user/c/calviani/root/include/TSeqCollection.h:26, from /afs/cern.ch/user/c/calviani/root/include/TList.h:26, from /afs/cern.ch/user/c/calviani/root/include/TNamed.h:29, from /afs/cern.ch/user/c/calviani/root/include/TTree.h:30, from marco_new_single.c:31: /usr/include/bits/mathcalls.h:110: error: expected initializer before "l" /usr/include/bits/mathcalls.h:110:1: pasting "__" and "(" does not give a valid preprocessing token /usr/include/bits/mathcalls.h:110: error: conflicting declaration 'long double __' /usr/include/bits/mathcalls.h:110: error: '__' has a previous declaration asdouble __’
/usr/include/bits/mathcalls.h:110: error: type mismatch with previous external decl of long double __' /usr/include/bits/mathcalls.h:110: error: previous external decl ofdouble __’
/usr/include/bits/mathcalls.h:110: error: declaration of long double __' /usr/include/bits/mathcalls.h:110: error: conflicts with previous declarationdouble __’
/usr/include/bits/mathcalls.h:110:1: pasting “)” and “l” does not give a valid preprocessing token
/usr/include/bits/mathcalls.h:110: error: cannot convert void (*)(int, char*, ...)' tolong double’ in initialization
/usr/include/bits/mathcalls.h:110: error: expected ,' or;’ before "l"
In file included from /afs/cern.ch/user/c/calviani/root/include/TString.h:32,
from /afs/cern.ch/user/c/calviani/root/include/TCollection.h:34,
from /afs/cern.ch/user/c/calviani/root/include/TSeqCollection.h:26,
from /afs/cern.ch/user/c/calviani/root/include/TList.h:26,
from /afs/cern.ch/user/c/calviani/root/include/TNamed.h:29,
from /afs/cern.ch/user/c/calviani/root/include/TTree.h:30,
from marco_new_single.c:31:
/afs/cern.ch/user/c/calviani/root/include/TMath.h: In function Double_t TMath::Log(Double_t)': /afs/cern.ch/user/c/calviani/root/include/TMath.h:638: warning: converting toint’ from `Double_t’
/afs/cern.ch/user/c/calviani/root/include/TMath.h:638: error: too few arguments to function
/afs/cern.ch/user/c/calviani/root/include/TMath.h:638: error: void value not ignored as it ought to be

The following are the “include” i’ve added in my program:

#include “dblock.h”
#include “event_build.h”
#include
#include
#include
#include
#include
#include “EVprototypes.h”
#include

What can be the cause of this?
PS: i’m using ROOT 5.14/00

Regards,
Marco

Could you post as attachment the shortest possible autonomous setup reproducing your problem?
Also indicate your system and version of the compiler.

Rene

Hi Rene,
ok. I’m using lx32slc4 machines with gcc version 3.4.6 20060404.

The very simple program is this:

#include <shift>
#include <stdlib>
#include <string>
#include <TTree>

int main(int argc, char **argv)
{
  printf("Test");
}

(of course there are the .h after each include. I.e. is actually , i don’t know why this happened (is not appearing even now))

and the command i’m executing is this:

I think the program resides in including the shift.h file.

Regards,
Marco

Follow-up:

this is the results obtained running the very same program and execution line on lxplus.cern.ch (gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-56))

In file included from /usr/include/math.h:65,
from /afs/cern.ch/user/c/calviani/root/include/TMath.h:525,
from /afs/cern.ch/user/c/calviani/root/include/TString.h:32,
from /afs/cern.ch/user/c/calviani/root/include/TCollection.h:34,
from /afs/cern.ch/user/c/calviani/root/include/TSeqCollection.h:26,
from /afs/cern.ch/user/c/calviani/root/include/TList.h:26,
from /afs/cern.ch/user/c/calviani/root/include/TNamed.h:29,
from /afs/cern.ch/user/c/calviani/root/include/TTree.h:30,
from test_er.c:4:
/usr/include/bits/mathcalls.h:110: conflicting types for double (*logfunc)(double)' /usr/include/shift/log.h:20: previous declaration asvoid (logfunc)(int,
char
, …)’
/usr/include/bits/mathcalls.h:110: function double __(double)' is initialized like a variable In file included from /usr/include/math.h:88, from /afs/cern.ch/user/c/calviani/root/include/TMath.h:525, from /afs/cern.ch/user/c/calviani/root/include/TString.h:32, from /afs/cern.ch/user/c/calviani/root/include/TCollection.h:34, from /afs/cern.ch/user/c/calviani/root/include/TSeqCollection.h:26, from /afs/cern.ch/user/c/calviani/root/include/TList.h:26, from /afs/cern.ch/user/c/calviani/root/include/TNamed.h:29, from /afs/cern.ch/user/c/calviani/root/include/TTree.h:30, from test_er.c:4: /usr/include/bits/mathcalls.h:110: syntax error before(’ token
/usr/include/bits/mathcalls.h:110: float __' redeclared as different kind of symbol /usr/include/bits/mathcalls.h:110: previous declaration ofdouble __(double)’
/usr/include/bits/mathcalls.h:110: cannot convert double (*)(double)' to
float’ in initialization
/usr/include/bits/mathcalls.h:110: syntax error before (' token In file included from /usr/include/math.h:109, from /afs/cern.ch/user/c/calviani/root/include/TMath.h:525, from /afs/cern.ch/user/c/calviani/root/include/TString.h:32, from /afs/cern.ch/user/c/calviani/root/include/TCollection.h:34, from /afs/cern.ch/user/c/calviani/root/include/TSeqCollection.h:26, from /afs/cern.ch/user/c/calviani/root/include/TList.h:26, from /afs/cern.ch/user/c/calviani/root/include/TNamed.h:29, from /afs/cern.ch/user/c/calviani/root/include/TTree.h:30, from test_er.c:4: /usr/include/bits/mathcalls.h:110: syntax error before(’ token
/usr/include/bits/mathcalls.h:110: conflicting types for long double __' /usr/include/bits/mathcalls.h:110: previous declaration asfloat __’
/usr/include/bits/mathcalls.h:110: cannot convert double (*)(double)' tolong
double’ in initialization
/usr/include/bits/mathcalls.h:110: syntax error before `(’ token

[quote]/usr/include/bits/mathcalls.h:110: conflicting types for double (*logfunc)(double)' /usr/include/shift/log.h:20: previous declaration asvoid (logfunc)(int,
char
, …)’ [/quote]This indicates that shift/log.h (From castor) is unfortunately re-using a symbol used in the standard headers … (mathcalls.h) … actually looking more carefully log.h contains …:

#ifdef log #undef log #endif #define log (*logfunc) /* logging function name */
… so to solve your problem just do

#include <shift> #undef log

Cheers,
Philippe.

Thanks Philippe,
now it works.

Regards,
marco