to make a compiled global visibile from the interpreter add:
#pragma link C++ global gHades;
in your LinkDef.h file. See also:
http://root.cern.ch/cgi-bin/print_hit_bold.pl/root/roottalk/roottalk97/0442.html?pragma#first_hit
Yor code just becomes:
Hades::Hades()
{
gHades = this;
...
}
Cheers, Fons.
Manuel Sanchez Garcia wrote:
>
> Hello All
>
> My question is the following; How could i share one variable betwen
> the compiled code and the interpreter?. Just in the same way gROOT or
> gSystem are accesible from both compiled code and the interpreter.
>
> At the moment I've tried to do it with the following code
>
> Hades::Hades(void) {
> Hades **p;
> TGlobal *gl;
>
> gHades=this;
>
> gROOT->Reset();
> gROOT->ProcessLine("Hades *gHades;");
> gROOT->ProcessLine("#include \"HadDef.h\"");
> gl=gROOT->GetGlobal("gHades",kTRUE);
> p=(Hades **)gl->GetAddress();
> *p=gHades;*/
>
> }
>
> that works if i create an objecto of the class Hades within the
> interpreter; but i get a segmentation violation if i try to do it in
> compiled code.
>
> Thanks, Manuel
> ------------------------------------------------
> Hades
> GSI
-- 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