Re: Error: No memory for static ...

From: Philippe Canal <pcanal_at_fnal.gov>
Date: Fri, 3 Oct 2008 12:35:37 -0500


Hi Roger,

Handling of static variable is one of the current weakness in CINT. To work around the problem simply use this alternative ordering of the code: (or use ACLiC).

void read_tree_minimal()
{

   static Double_t energy;

   TFile *f = new TFile("Ca1Mn47d.lowsanidined.20080506.135053.root");    return;
}

Cheers,
Philippe.

Roger Mason wrote:
> Hello,
>
> I'm trying to write a macro to read in values from a TTree in a root
> file. The following minimal example fails:
>
> #include "TFile.h"
> #include "TTree.h"
> #include "TBrowser.h"
> #include "TH2.h"
> #include "TRandom.h"
> #include "TCanvas.h"
>
> void read_tree_minimal()
> {
>
> TFile *f = new TFile("Ca1Mn47d.lowsanidined.20080506.135053.root");
> static Double_t energy;
> return;
> }
>
> root [0] .x read_tree_minimal.C
> Error: No memory for static energy\23b\0 read_tree_minimal.C:12:
>
> The same macro compiles without error:
>
> root [1] .x read_tree_minimal.C++
> Info in <ACLiC>: script has already been loaded in interpreted mode
> Info in <ACLiC>: unloading /home/rmason/test/root/./read_tree_minimal.C and compiling it
> Info in <TUnixSystem::ACLiC>: creating shared library /home/rmason/test/root/./read_tree_minimal_C.so
> /home/rmason/test/root/./read_tree_minimal.C: In function 'void read_tree_minimal()':
> /home/rmason/test/root/./read_tree_minimal.C:11: warning: unused variable 'f'
> /home/rmason/test/root/./read_tree_minimal.C:12: warning: unused variable 'energy'
>
> Perhaps someone would be kind enough to point out what is wrong.
>
> Thanks,
> Roger
>
> Gentoo linux:
>
> *******************************************
> * *
> * W E L C O M E to R O O T *
> * *
> * Version 5.20/00 24 June 2008 *
> * *
> * You are welcome to visit our Web site *
> * http://root.cern.ch *
> * *
> *******************************************
>
> ROOT 5.20/00 (trunk_at_24524, Oct 01 2008, 15:00:00 on linux)
>
>
Received on Fri Oct 03 2008 - 19:36:25 CEST

This archive was generated by hypermail 2.2.0 : Fri Oct 03 2008 - 23:50:02 CEST