From: JCO on
What exactly is the difference. This has always bothered me that this is
the case. I've noticed that you cannot substitute one for the other. I'm
guessing TRUE was the original way of doing things before "true" came along?
The same case can be made with FALSE vs false.

Thanks


From: r norman on
On Wed, 16 Jun 2010 09:23:44 -0500, "JCO" <someone(a)somewhere.com>
wrote:

>What exactly is the difference. This has always bothered me that this is
>the case. I've noticed that you cannot substitute one for the other. I'm
>guessing TRUE was the original way of doing things before "true" came along?
>The same case can be made with FALSE vs false.
>

Compare sizeof(TRUE) with sizeof(true).

I believe TRUE/FALSE were introduced before true/false became standard
in C (and then C++). Once they were well entrenched in the Windows
libraries it would have broken too much old code to change everything
to be consistent.

From: JCO on
int x = sizeof(true);
int y = sizeof(TRUE);

x is 1
y is 4
Okay so the size if different?
I always attempt to use lowercase when possible.

"r norman" <r_s_norman(a)comcast.net> wrote in message
news:haoh16pjir0uk12jdjdrdih03gi4g0kfgp(a)4ax.com...
> On Wed, 16 Jun 2010 09:23:44 -0500, "JCO" <someone(a)somewhere.com>
> wrote:
>
>>What exactly is the difference. This has always bothered me that this is
>>the case. I've noticed that you cannot substitute one for the other. I'm
>>guessing TRUE was the original way of doing things before "true" came
>>along?
>>The same case can be made with FALSE vs false.
>>
>
> Compare sizeof(TRUE) with sizeof(true).
>
> I believe TRUE/FALSE were introduced before true/false became standard
> in C (and then C++). Once they were well entrenched in the Windows
> libraries it would have broken too much old code to change everything
> to be consistent.
>
From: Stephen Myers on
JCO wrote:
> int x = sizeof(true);
> int y = sizeof(TRUE);
>
> x is 1
> y is 4
> Okay so the size if different?
> I always attempt to use lowercase when possible.
>
> "r norman" <r_s_norman(a)comcast.net> wrote in message
> news:haoh16pjir0uk12jdjdrdih03gi4g0kfgp(a)4ax.com...
>> On Wed, 16 Jun 2010 09:23:44 -0500, "JCO" <someone(a)somewhere.com>
>> wrote:
>>
>>> What exactly is the difference. This has always bothered me that
>>> this is
>>> the case. I've noticed that you cannot substitute one for the
>>> other. I'm
>>> guessing TRUE was the original way of doing things before "true" came
>>> along?
>>> The same case can be made with FALSE vs false.
>>>
>>
>> Compare sizeof(TRUE) with sizeof(true).
>>
>> I believe TRUE/FALSE were introduced before true/false became standard
>> in C (and then C++). Once they were well entrenched in the Windows
>> libraries it would have broken too much old code to change everything
>> to be consistent.
>

TRUE and FALSE are the original C way of doing things.

Windows defines a BOOL data type which is a 32 integer. This
corresponds to TRUE and FALSE.

You should be able to find #define typedef or enum definitions for BOOL,
TRUE and FALSE.

The bool data type is a relatively recent addition and is supported
internally by the compiler. It's size is normally a byte.

HTH
Steve
From: Joseph M. Newcomer on
TRUE and FALSE were defined by Windows many, many years ago, long before there was a
Boolean data type (one of the major design defects of the C language, but the list of
design defects is far too long to go into here!)

The BOOL data type is really
typedef int BOOL;
in the Windows header files (not MFC, as some people believe)

C++ corrected the C design defect by adding a type bool and constants true and false.

The problem arises when there is the unfounded belief that a BOOL type can only be TRUE or
FALSE; essentially, it can be FALSE or non-FALSE (any value other than 0 is non-FALSE)
where TRUE is one particular value, the constant 1.

Thefore, it is nonsensical to take a function of the form
BOOL function(...);
and write something of the form
if(function(...) == TRUE)

because the value might not be 1. Unfortunately, due to terminal brain rot, the Win9X
series of imitation operating systems often returned a non-zero value not equal to 1. This
failure has been propagated into any number of libraries that claim to return BOOL but in
fact can return non-FALSE values that are not equal to TRUE.

The correct test, of course is to write
if(function(...))
and this also applies to BOOL variables; NEVER write
if(var == TRUE)
but ALWAYS
if(var)
and never write
if(var == FALSE)
but write
if(!var)

It is completely foolish to EVER compare a BOOL (or even bool) value to a literal like
TRUE, true, FALSE or false; it is about as silly as writing
if((a > 0) == true)
A boolean value is ALREADY a testable value and it never makes sense to compare it to a
literal boolean to get, guess what, a boolean value! In the case of BOOL, it is
dangerous.

It is not a good idea when doing Windows programming to substitute bool for BOOL anywhere;
it will only lead to problems. In fact, it is not clear what, if any, advantage bool has
for Windows programmers (note that if you are using std:: or creating operators in C++,
you should use the bool type because this is not Windows programming!)
joe
On Wed, 16 Jun 2010 09:23:44 -0500, "JCO" <someone(a)somewhere.com> wrote:

>What exactly is the difference. This has always bothered me that this is
>the case. I've noticed that you cannot substitute one for the other. I'm
>guessing TRUE was the original way of doing things before "true" came along?
>The same case can be made with FALSE vs false.
>
>Thanks
>
Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm