Re: [ROOT] scope of local variables in cint

From: Jiri Masik (masik@fzu.cz)
Date: Fri May 02 2003 - 16:56:28 MEST


"Walter F.J. Mueller" <W.F.J.Mueller@gsi.de> writes:

> This is a multi-part message in MIME format.
> --------------050500070401090200010001
> Content-Type: text/plain; charset=us-ascii; format=flowed
> Content-Transfer-Encoding: 7bit
>
> Dear ROOTers,
>
> the attached little script "demo.C" works fine when executed
> with ACLiC. However, when just interpreted with CINT I get
> the error message
>
>    Processing demo.C...
>    Error: p already declared as different type FILE:demo.C LINE:17
>    *** Interpreter error recovered ***
>
> So CINT seems to have a problem handling the scope of the
> variables correctly. It seems that somehow the type of the first
> declaration of 'p' is memorized and the interpreter chokes when a
> variable with this name is declared a second time.
>
> Is this a restriction in CINT ?
>
>
> 		Cheers,	Walter
>
> --
> Walter F.J. Mueller   Mail:  W.F.J.Mueller@gsi.de
> GSI,  Abteilung KP3   Phone: +49-6159-71-2766
> D-64291 Darmstadt     FAX:   +49-6159-71-2989
> WWW:   http://www-kp3.gsi.de/www/kp3/people/mueller.html
>
> --------------050500070401090200010001
> Content-Type: text/x-csrc;
>  name="demo.C"
> Content-Transfer-Encoding: 7bit
> Content-Disposition: inline;
>  filename="demo.C"
>
> #ifndef __CINT__
> #include "TCanvas.h"
> #include "TLine.h"
> #include "TBox.h"
> #endif
>
> void demo()
> {
>   TCanvas* c1 = new TCanvas("c1", "" , 20,20,700,900);
>
>   if (1) {
>     TLine* p = new TLine(0.,0.,1.,1.);
>     p->Draw();
>   }
>
>   if (1) {
>     TBox* p = new TBox(0.4,0.4,0.6,0.6);
>     p->Draw();
>   }
>
>   c1->Update();
> }
>
> --------------050500070401090200010001--

Hi Walter,

it is a limitation of cint - it is documented in
http://root.cern.ch/root/Cint.phtml?limitations - function scope
cheers

Jiri



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:11 MET