Re: [ROOT] Should Bool_t still be typedef'ed to unsigned char

From: Fons Rademakers (Fons.Rademakers@cern.ch)
Date: Tue Nov 27 2001 - 11:36:20 MET


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