Board index » cppbuilder » bools from hell.

bools from hell.


2007-11-27 08:32:42 AM
cppbuilder62
In the Borland help section it states that we can use bool, true, and false.
Is this restricted to C++ only?
bool Running; <---- syntax error
bool MyBool; <----multiple bool declarations
Running = false; < I don't remember but an error here as well.
If I try....
BYTE Running;
Running = true; < then I get an error here as well.
So, I made some constants called:
const BYTE TRUE = 1;
const BYTE FALSE = 0;
well, you already know what happens... It compiles fine, but it sure
doesn't run like I would expect.
Oh, they are reserved keywords.... Hum.
So what gives? How in the world do I use something as simple as booleans?
Seems pretty straight forward in every other language I used so I must be
over looking something.
Richard
 
 

Re:bools from hell.

I found this in some other source, it seems to imply there is no bool in C,
unless you define it yourself???
#define true 1
#define false 0
typedef int bool;
Then even, why would someone use an int for a bool when a byte (char) is
much smaller?
#define true 1
#define false 0
typedef BYTE bool;
I take it that would work just as well?
Richard
"Richard" <rwskinner@ATccwipDOTnet>wrote in message
Quote
In the Borland help section it states that we can use bool, true, and
false.
Is this restricted to C++ only?

bool Running; <---- syntax error
bool MyBool; <----multiple bool declarations


Running = false; < I don't remember but an error here as well.


If I try....

BYTE Running;
Running = true; < then I get an error here as well.

So, I made some constants called:
const BYTE TRUE = 1;
const BYTE FALSE = 0;

well, you already know what happens... It compiles fine, but it sure
doesn't run like I would expect.
Oh, they are reserved keywords.... Hum.

So what gives? How in the world do I use something as simple as booleans?
Seems pretty straight forward in every other language I used so I must be
over looking something.

Richard


 

Re:bools from hell.

Hi Richard
Have you tried with boolean or BOOL
Just an idea from some old code i have.
Do You have a very old compilor ?
en.wikipedia.org/wiki/Boolean_datatype
Kind regards
Asger
 

{smallsort}

Re:bools from hell.

There is not such built-in type as bool in C89. However AFAIK in C99 a new
type _Bool was introduced but logical constant true and false are absent.
There is such header file as stdbool.h where the following macros bool,
true, and false are defined.
Also if you write for Windows in windef.h the macros BOOL, TRUE, and FALSE
are defined.
Vladimir Grigoriev
"Richard" <rwskinner@ATccwipDOTnet>wrote in message
Quote
I found this in some other source, it seems to imply there is no bool in
C, unless you define it yourself???

#define true 1
#define false 0
typedef int bool;

Then even, why would someone use an int for a bool when a byte (char) is
much smaller?
#define true 1
#define false 0
typedef BYTE bool;

I take it that would work just as well?

Richard


"Richard" <rwskinner@ATccwipDOTnet>wrote in message
news: XXXX@XXXXX.COM ...
>In the Borland help section it states that we can use bool, true, and
>false.
>Is this restricted to C++ only?
>
>bool Running; <---- syntax error
>bool MyBool; <----multiple bool declarations
>
>
>Running = false; < I don't remember but an error here as well.
>
>
>If I try....
>
>BYTE Running;
>Running = true; < then I get an error here as well.
>
>So, I made some constants called:
>const BYTE TRUE = 1;
>const BYTE FALSE = 0;
>
>well, you already know what happens... It compiles fine, but it sure
>doesn't run like I would expect.
>Oh, they are reserved keywords.... Hum.
>
>So what gives? How in the world do I use something as simple as
>booleans? Seems pretty straight forward in every other language I used so
>I must be over looking something.
>
>Richard
>
>


 

Re:bools from hell.

"Asger Joergensen" < XXXX@XXXXX.COM >wrote in message
Quote

Hi Richard

Have you tried with boolean or BOOL

Just an idea from some old code i have.

Do You have a very old compilor ?
en.wikipedia.org/wiki/Boolean_datatype

This group *is* for a very old compiler (from 1997).
--
Bruce