Re: What's #included when?

Fons Rademakers (Fons.Rademakers@cern.ch)
Mon, 13 Oct 1997 19:17:23 +0200


Hi Christian,

the problem is that the statement gROOT->Reset() removes the
iostream.h symbols from the interpreter environment. After that
you get a problem with CINT still thinking that the iostream.h
file is loaded and therefore refusing to load it again.

A solution to the above problem is to include iostream.h in the
rootalias.C (or rootlogon.C) macro. All functions and symbols
created in these macros will not be removed by gROOT->Reset().

So check in your .rootrc file (or in the global $ROOTSYS/.rootrc)
that there is a line like:

Rint.Load: rootalias.C

now add in the file rootalias.C:

#include <iostream.h>

Cheers, Fons.

>
> Hello Rooters,
>
> I've become mystified by a certain strange situation.
>
> Step 1) Run root (on my Linux box) and try outputing some things.
>
> *******************************************
> * *
> * W E L C O M E to R O O T *
> * *
> * Version 1.03/04 1 October 1997 *
> * Development version *
> * *
> * You are welcome to visit our Web site *
> * http://root.cern.ch *
> * *
> *******************************************
>
> CINT/ROOT C/C++ Interpreter version 5.13.28, Sep 23 1997
> Type ? for help. Commands must be C++ statements.
> Enclose multiple statements between { }.
> root [0] cout << 1 << endl;
> Error: No symbol cout in current scope FILE:/tmp/08222aaa LINE:1
> Error: No symbol endl in current scope FILE:/tmp/08222aaa LINE:1
> (int)0
> *** Interpreter error recovered ***
> root [1]
>
> Step 2) Ok, that was just a test. It makes sense that you can't use cout
> yet because I haven't #included <iostream.h> So let's do that.
>
> root [1] #include <iostream.h>
> root [2] cout << 1 << endl;
> 1
>
> Step 3) Ok. Cool. No problem. Let's try executing a macro that
> requires cout.
>
> root [3] .x h101.C
> Error: No symbol cout in current scope FILE:/home/nally/snoroot/./h101.C
> LINE:70
> Error: L Illegal operator for pointer 3 FILE:/home/nally/snoroot/./h101.C
> LINE:70
> Error: L Illegal operator for real number
> FILE:/home/nally/snoroot/./h101.C LINE:70
> Error: L Illegal operator for pointer 3 FILE:/home/nally/snoroot/./h101.C
> LINE:70
> *** Interpreter error recovered ***
> root [4]
>
> Step 4) Well... that wasn't so good. But I'm not certain what the problem
> was. Shouldn't the include have worked for that macro? (If you are very
> curious, the source of the macro is at
> http://www.physics.ubc.ca/~nally/phd/h101.C
> ) But now, let's try the old stream test.
>
> root [4] cout << 1 << endl;
> Error: No symbol cout in current scope FILE:/tmp/08222caa LINE:1
> Error: L Illegal operator for pointer 3 FILE:/tmp/08222caa LINE:1
> root [5]
>
> Step 5) Darn! It used to work. Ok... I'll try to reinclude the iostream.h
>
> root [5] #include <iostream.h>
> Warning: File "iostream.h" already loaded
> root [6]
>
> Step 6) Hmmm... ok. Let's try again then...
>
> root [6] cout << 1 << endl;
> Error: No symbol cout in current scope FILE:/tmp/08222eaa LINE:1
> Error: L Illegal operator for pointer 3 FILE:/tmp/08222eaa LINE:1
> root [7]
>
> Step 7) AAAhhhhh!!!! Fons, Nenad, Rene, Masaharu, Pasha, and others Help!?
>
> Thanks from a confused guy. :-)
>
> -------------------------------------------------------------------------
> Christian Nally | UBC Physics | SNO Group | Vancouver, B.C., Canada
> nally@physics.ubc.ca http://www.physics.ubc.ca/~nally
> -------------------------------------------------------------------------

-- 
Org:    CERN, European Laboratory for Particle Physics.
Mail:   1211 Geneve 23, Switzerland          Phone: +41 22 7679248
E-Mail: Fons.Rademakers@cern.ch              Fax:   +41 22 7677910