Using Compiled Macros

Hi folks,

I’ve been using a macro with the CINT, but I decided to try to compile it and run it as an executable, so I followed the test example for hsimple.cxx with the corresponding Makefile. It compiles just fine and runs, but there is a strange problem with TNtuple, in that the string I use for the variable names somehow does not get passed properly. I find this is very strange because it works just fine when I run the macro through CINT.

By the way, I’m using Root 5.18/00 on a PowerPC Powerbook, but I have the same problems with 5.14/00e on my RHEL desktop.

I’ve attached my macro. I tried to also attach the makefile, but it wouldn’t work… Anyway, it is the standard one from the ‘test’ directory.

Any help would be much appreciated.


Comp.cxx (1.44 KB)

Hi Dave,

it’s a problem with temporaries; the TString object returned by GetName() is invalidated right after the return from GetName(), and then the adress referenced by TString.Data() (the one you store in names) is invalid. Make names a TString instead.

Cheers, Axel.

Hi Axel,

Thanks very much for the super-quick response. That did the trick.

I did originally try to make the string a TString instead of a const char*, but for some reason it didn’t work at that time.

It did work this time, though.

Vielen Dank!