[ROOT] Using union in ROOT object

From: guez (guez@ipno.in2p3.fr)
Date: Wed Mar 14 2001 - 16:31:54 MET


Hello,

In the code below, there is a problem with rootcint generated code. 

union Value_t
{
  Int_t IVal; //value when Int  
  Float_t FVal; //value when Float
};

class TBValue : public TObject
{
 protected:

  Type_t fType;
  Value_t fValue;  // value

 public:
....
  Value_t GetValue(){return fValue;}
....

}

With this code, the rootcint dictionnary seems to be correctly
generated, but cannot be compiled (with ROOT 3.00/05 and egcs-2.91.66
under Linux RedHat).  

With the following command :
 
rootcint -f TBDataBaseDict.C -c TBADCModule.h  ...all my .h files ...
TBProperty.h TBView.h TBDataBase_LinkDef.h;

the compiler returns the following error :

Dictionnary compilation : TBDataBaseDict.o
generated/TBDataBaseDict.C: In function `int
G__TBValue_GetValue_3_0(struct G__value *, const char *, struct G__param
*, int)':
generated/TBDataBaseDict.C:2196: `union Value_t' used where a `long int'
was expected
gmake: *** [TBDataBaseDict.o] Error 1


If I replace, in the source file, the return type of GetValue() by a
reference to a Value_t, everything compiles successfully

....
  Value_t &GetValue(){return fValue;}
....

So, my question is : I would like to be able to obtain a direct value
from the union without having to use a reference. Is this possible or 
a normal limitation of CINT/ROOT.

Thanks a lot

	David

--
David GUEZ
addresse : 15, rue Georges Clemenceau    *   mail: guez@ipno.in2p3.fr
91406 Orsay Cedex                        *   tel : (+33) 1 69 15 51 39
Batiment 100 - Bureau 125                *



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:39 MET