Is there a problem with using TROOT::LoadMacro on a macro with static variables? To illustrate with a toy example: if file a.C contains: ======== void a () { static Int_t x0 = 200; } ======== and file b.C contains: ======== void b() { gROOT->LoadMacro ("a.C"); a(); } ======== then if I try to load b.C and execute it, it works; but if I execute it again, I get an error: ======== root [0] .L b.C root [1] b() root [2] b() Function b() busy. loaded after "/auto/mepdisk/src/happex/pan/./macro/b.C" Error: G__unloadfile() Can not unload "/auto/mepdisk/src/happex/pan/./macro/b.C", file busy FILE:macro/b.C LINE:3 *** Interpreter error recovered *** ======== If I remove the keyword "static" from a.C, this error does not occur. I am using ROOT 3.03/09 under Red Hat 7.3. (Of course I could omit the LoadMacro and just do .L a.C before executing b(), but there are two objections to this. First, in the real world when a macro relies on several other macros to be loaded, this becomes a nuisance. Second, if the loaded macro alters the value of the static variable when it executes, then the static variable maintains its current value that way, while presumably if LoadMacro were used successfully it should return the static variable to its initial value... I should think.) -- Richard S. Holmes, Research Assistant Professor Physics Department, Syracuse University Syracuse, NY 13244 (315) 443-5977
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:20 MET