Hi, That means Bool_t will change from a type of size 1 byte to a type of size 4 byte (at least on SUN). Isn't that a problem when I will read ROOT files which were created with an old version? root [0] int a = sizeof(bool) root [1] a (int)4 root [0] int b = sizeof(unsigned char) root [1] b (int)1 Cheers Reiner. On 27-Nov-01 at 11:58, Fons Rademakers (Fons.Rademakers@cern.ch) wrote: > We agree and this will be done in a next major release. In the meanwhile > we make sure that all compilers support bool. > > Cheers, Fons. > > > > On Monday 26 November 2001 21:45, Walter F.J. Mueller wrote: > > Hello, > > > > Bool_t is typedef'ed to `unsigned char' in Rtypes.h. As an unfortunate > > consequence this boolean looking types behaves different than the native > > bool type in at least two ways: > > > > 1. stream output: > > > > root [0] Bool_t b1 = kTRUE; > > root [1] cout << b1 << endl; > > > > will write a binary 1 into cout, while > > > > root [2] bool b2 = true; > > root [3] cout << b2 << endl; > > > > gives the expected `1'. > > > > 2. Implicit conversions: > > > > root [0] Bool_t b1 = 0x0100; > > root [1] b1 > > (unsigned char)0 > > > > This is a real trap and caused in my case some obscure bugs when I > > ported some code into the ROOT environment. The C++ type bool simply > > has different semantics than stand-in Bool_t. > > > > The introduction of Bool_t was probably motivated by the fact that some > > compilers didn't support `bool' when ROOT was initially designed. By now, > > all contempory compilers should support `bool', so there is no need for > > this in my view potentially confusion typedef for `unsigned char'. > > > > As a consequence I wonder whether one shouldn't typedef Bool_t to bool > > in one of the next major releases. > > > > > > With best regards, > > > > Walter Mueller > > -- > Org: CERN, European Laboratory for Particle Physics. > Mail: 1211 Geneve 23, Switzerland > E-Mail: Fons.Rademakers@cern.ch Phone: +41 22 7679248 > WWW: http://root.cern.ch/~rdm/ Fax: +41 22 7679480
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:51:09 MET