I am working on Windows with VS 2013 and the latest debug version of root 5.34.34, I have some code that runs perfectly as an interpreted macro but I can’t make it work in a compiled program in VS. The code builds correctly, but it doesn’t do what it should.
In the attached example I’m trying to read a root file containing an NTuple (called “pjmca”) and copying its data as TH1F in a new root file. Notice that at the beginning I have commented
//TApplication *a = new TApplication("a", 0, 0);
If you leave that as it is, you’ll notice that the program finds that pjmca has 0 entries and therefore doesn’t copy anything in the new TH1Fs. If instead you uncomment that line,
GetEntries() works fine, but after 4-5 iterations of the for loop all my variables change their values at random as if some pointer had invaded them and changed them.
The fun part is that if you take that read function in a new file (without TApplication) and interpret it as a macro it all works perfectly.
On other operating systems this code seems to work both as a compiled program and as a macro, but is there anything I can do to make it work on Windows with VS?