Hello Stelios. The original code is WRONG from the C++ syntax point of view. This is what you were said by the C++ compiler. You were confused with the smart CINT/ROOT behavior. That allows skipping the declaration of the object in the ROOT macro if that object class CINT dictionary is loaded. That is NOT possible with the compiled code. In your case CINT (on ROOT behalf) automatically creates a new variable "c1" - the "pointer" to the object class. ROOT knows (via TObject::Class() method) the object class definition from the CINT dictionary and it can "ask" CINT to create the new variable "automatically". In your case it is "c1". The name of the variable is chosen from the object name and the type of this variable is the pointer to the object class namely "TCanvas". Apparently such level of cooperation is not possible between the ROOT and real compiler. So you must avoid the CINT/ROOT C++ extensions those are appropriated for the interactive session. It can be a part of CINT /ROOT macros as well. However they are no use with the normal compiler. Hope this helps, Valeri > -----Original Message----- > From: owner-roottalk@pcroot.cern.ch [mailto:owner-roottalk@pcroot.cern.ch] > On Behalf Of Christian Vogel > Sent: Saturday, July 31, 2004 6:07 PM > To: Stilianos Kesisoglou > Cc: roottalk@pcroot.cern.ch > Subject: Re: [ROOT] compilation problem (corrected) > > Hi, > > I re-indented your function to make my point more clear: > > On Sat, Jul 31, 2004 at 02:18:45PM -0500, Stilianos Kesisoglou wrote: > > void Performance() > > { > > if ((TCanvas*)gROOT->GetListOfCanvases()->FindObject("c1")){ > > c1->Clear(); /* <--- HERE c1 is not declared! */ > > } else { > > TCanvas *c1 = new TCanvas(); > > } > > } > > You proably want to do something like this: > > { > TCanvas *c1 = gROOT->GetListOfCanvases()->FindObject("c1"); > if(c1) > c1->Clear(); > else > c1 = new TCanvas(); > > (...) > } > > Chris > > -- > Programming today is a race between software engineers striving to build > bigger and better idiot-proof programs, and the Universe trying to > produce bigger and better idiots. So far, the Universe is winning. > -- Rich Cook
This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:09 MET