Topic : bool, TRUE, FALSE is strange for compiler

Forum : ARM

Original Post
Post Information Post
September 27, 2011 - 7:00pm
Guest

Hello,

after months I have tried to compile again my project that was working well.
This turn I have
Ride7 7.30.10.0159
Rkit 1.30.10.0356
Ride7 Patch 7.30.10.0169

As I have mentioned, months ago (with older Ride) it was compiling well.

Now I get
error: 'bool' undeclared (first use in this function)
error: 'TRUE' undeclared (first use in this function)

Of course editor recognizes them (blue).

It must be something stupid.

Have you any idea?

Thanks for any help

Robert

I have used temporary: char, 1, 0 instead but worth to know for the future ?

Replies
Post Information Post
+1
0
-1
September 28, 2011 - 10:00am
Raisonance Support Team

Hi,

"bool" is not C but C++, this is why you have this behavior.
What you can do is to add:

typedef enum { FALSE, TRUE } bool;

This should fix your problem.

BTW, it is better to consider that 0 is FALSE, and TRUE can be anything else.
This means that you should always write :
if(condition)...

rather than

if(condition == TRUE)...

Readability is not different (perhaps even better) and it does not confuse the compiler with unnecessary casts.

+1
0
-1
September 28, 2011 - 4:35pm
Guest

Bruno,
thanks for your very quick response - again. :-)

I have remembered that there is something strange about "bool, TRUE, FALSE" but after a months of break in working with C I have forget what exactly.
Thanks again

Robert