Declaration of TRandom Object as "rand" causes redefinition error when running interactively

Hi Everyone,

The declaration of a TRandom instance as “rand” causes redefinition error when running interactively:

TCanvas *c1 = new TCanvas("c1","Candle Decay",800,600);
TRandom *rand = new TRandom();

This also causes the notebook (ROOTBook) to fail in the examples shown here


rand is definitely already defined, it’s the usual C random number generator function,
and it’s always in scope in the ROOT prompt (same as sin, cos and many others).

You will have to choose a more descriptive name for your variable, but this is not necessary a bad thing :stuck_out_tongue:


Yup. Then we should definitely have a more descriptive name of the TRandom object in $ROOTSYS/tutorials/hist/ as it causes the ROOTbook to fail as I pointed out before. :slight_smile:

I completely agree :smile:

This is now ROOT-9030, you can follow up there

1 Like

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