Hi Eddy, yes, this is an alignment problem. You should never assume that the compiler will align the elements of a struct without gaps. CINT itself will always align at an 8 bytes boundary. It is recommended to always specify the largest first. If you want to keep your struct unmodified, you have to create one branch for each element of the struct. Rene Brun On Thu, 1 Jun 2000, Eddy Offermann wrote: > Dear Rooters, > > I have a problem with the following macro: > > { // a macro > > typedef struct { > Int_t pos; > Int_t filler; > Double_t price; > } REC; > > REC rec; > > TTree *tree = new TTree("T", "table"); > tree->Branch("rec", &rec, "pos/I:filler/I:price/D",1000); > > rec.pos = 12345; > rec.filler = -2;; > rec.price= 12345/12.3; > tree->Fill(); > > tree->Show(0); > > } > > This will print out: > ======> EVENT:0 > pos = 12345 > filler = -2 > price = 1003.66 > > So far so good but now change the macro to (taking out Int_t filler): > > { // a macro > > typedef struct { > Int_t pos; > Double_t price; > } REC; > > REC rec; > > TTree *tree = new TTree("T", "table"); > tree->Branch("rec", &rec, "pos/I:price/D",1000); > > rec.pos = 12345; > rec.price= 12345/12.3; > tree->Fill(); > > tree->Show(0); > > } > > and you get : > > ======> EVENT:0 > pos = 12345 > price = 5.35141e-315 > > It seems there is some alignment problem and only the non-significant > bytes of price are shown ??? > > Eddy >
This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:27 MET