[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: Use true/false or TRUE/FALSE in KDE C++ programs?
From:       Richard Dale <Richard_Dale () tipitina ! demon ! co ! uk>
Date:       2005-05-29 13:36:48
Message-ID: 200505291536.48225.Richard_Dale () tipitina ! demon ! co ! uk
[Download RAW message or body]

On Sunday 29 May 2005 15:43, Nicos Gollan wrote:
> On Sunday May 29 2005 13:27, Richard Dale wrote:
> > I was wondering if there was a more correct boolean literal to use. I
> > noticed that the Qt docs have upper case booleans, but when I searched
> > the sources in kdelibs there were more instances of lower case ones.
>
> The thing with Qt is that it doesn't assume any standard-C++ features like
> namespaces, a working STL implementation or the standard boolean type
> "bool" to be present, so it defines its own of everything (just have a look
> at the comments in the Qt sources for the declaration of the class "Qt" in
> qnamespace.h to get the idea of not using namespaces). By using the
> uppercase variety, it avoids ambiguities on systems which do have a "bool"
> type with true/false values.
>
> The correct literals by the C++ standard are the lowercase true/false
> values, but that might cause problems on systems with Really Old(TM)
> compilers unless you handle that somehow, e.g. with autotools.
Well the QtRuby language bindings only work with ruby 1.8 onwards and not ruby 
1.6, so I'll stick with lower case booleans in the C++ code for that project.
But I never understood why C/C++ didn't have a boolean type right from the 
start.
I hate code which type puns ints into booleans such as:

if !strcmp("mything", "myotherthing') {
	..other difficult to read crap code
}

-- Richard
 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic