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
--
Walter F.J. Mueller Mail: W.F.J.Mueller@gsi.de
GSI, Abteilung KP3 Phone: +49-6159-71-2766
D-64291 Darmstadt FAX: +49-6159-71-2989
WWW: http://www-kp3.gsi.de/www/kp3/people/mueller.html
PGP: http://www-kp3.gsi.de/~mueller/pgp.shtml
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:51:09 MET