TF1 argument with different versions of root

Hello experts :slight_smile:

I have a macro, it works properly on a computer but not on a second one. I’ll call them PC-NEW and PC-OLD. Here are version details:

PC-NEW = ROOT 5.99/01 (trunk@47818, Dec 04 2012, 16:18:06 on linux)
PC-OLD = ROOT 5.18/00b (branches/v5-18-00-patches@22563, Apr 06 2010, 01:56:00 on linux)

This is a macro which reproduces the problem:

{ TF1 *f = new TF1("f","2*x",0,10); cout << f(4) << endl; }

If run on PC-NEW, a “8” is printed as expected. If run on PC-OLD and the output is the following:

Processing test.C…
Error: Can’t call TF1::operator()(4) in current scope test.C:3:
Possible candidates are…
(in TF1)
/usr/lib/root/5.18/ -1:-1 0 public: virtual Double_t TF1::operator()(const Double_t* x,const Double_t* params=0);
(in TFormula)
*** Interpreter error recovered ***

The best solution would be to upgrade the older version of root… but I cannot do it right now.
Is there any workaround to use that piece of code with ROOT 5.18?

Thanks in advance!