kFALSE or kTRUE in TF1

I guess I have forgotten something because I get errors, with both ROOT 5 and ROOT 6, when I try:

TF1 *f1 = new TF1("f1", "TMath::Gaus(x, [0], [1], kFALSE)", -10, 10);
TF1 *f2 = new TF1("f2", "TMath::Gaus(x, [0], [1], kTRUE)", -10, 10);

If I use “0” and “1” instead of “kFALSE” and “kTRUE”, it works fine. With ROOT 6 I can also use “false” and “true” (but not with ROOT 5).

Yes with ROOT 6 I get:

root [0] TF1 *f1 = new TF1("f1", "TMath::Gaus(x, [0], [1], kFALSE)", -10, 10);
input_line_12:2:105: warning: braces around scalar initializer [-Wbraced-scalar-init]
Double_t TFormula____id14400478236249973786(Double_t *x,Double_t *p){ return TMath::Gaus(x[0],p[0],p[1],{kFALSE}) ; }
                                                                                                        ^~~~~~~~

it looks like this ROOT specific constant is not interpreted properly in that case…
May be @moneta can give an explanation ?

Hi,

I can add the support for this, but you have to recognise that kFALSE is not a valid C++ statement. It is valid in ROOT, but only when you have included a specific header file. Since a trivial workaround exists, I am not sure how really important is to implement this

Lorenzo

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.