A TFile on the stack or the heap doesn't seem to behave the same way...

Gordon Watts (gwatts@fnal.gov)
Tue, 14 Oct 1997 11:12:42 -0500


Hi,
I'm running 1.03/04 on WindowsNT 4.0, Service pack 3. I have the
following macro in a file test.c:

void test (char *filename)
{
TFile f (filename);
TFile *t = new TFile (filename);
TFile z ("junk.txt");
}

In root I run it with ".X test.c("junk.txt");" Junk.txt does not exist in
my current directory, so I expect all three statements to fail. Runnning it
shows that the second two do, indeed, produce an error message. No error
message is forthcoming from the first TFile delc. In fact, the object "f"
doesn't even seem to exist! (i.e. I can't do a IsOpen on it). I searched
the web site and documentation the best I could and the only clue I could
come up with is that TFile's constructor wants an argument of Text_t. I
tried replacing the char * with a Text_t * but it didn't change anything.
BTW, the error message from the second TFile decl indicates that the
"junk.txt" string is getting in just fine.

I also looked at the root/cint docs to see if there was some restriction on
stack created objects, but I didn't see any references...

Cheers,
Gordon.