EasyC 4 for Cortex: true, false appear as if keywords

Hi, a question arose in the weekly Vex team meeting: Why are the words ‘true’ and ‘false’ highlighted as if to indicate that they are keywords? E.g., while (true) {…}. The result of compiling such code is an error. Also, do any headers that are installed with EasyC contain macros or variables for these constant values?

In global variables you can #define constants. If you wanted you could define true and false.

#define true 1
#define false 0

while (true) { //true is the expression
//code
}

The example it to point out what needs to go inside the parenthesis. Basically a while loop, will loop while the expression is true and will stop looping once the expression is false. All controller cares about with while/for/if/else-if is the expression true or false.

while (1) //infinte loop

x= 5; // set x to 5
while ( x > 3 ) //true loop
while ( 5 == x) //true loop
while ( x > 10 ) // false don’t loop

Thanks for the quick response. I appreciate the tip on the use of the #define statements, and will make use of them. However, my main question, re-phrased, is essentially this: If neither true or false are C keywords (and in fact without the #define statements that you recommend are compilation errors) why do they appear in a blue font in EasyC 4 for Cortex. Using a very simple program I wrote as a guide, the only other words that seem to be blue rather than black are C keywords, like ‘if’, ‘while’ and ‘continue’.

Thanks,
Brian

Can you send me a screen shot, I’m not sure where you are seeing this.

Here it is.

-Brian
bluetrue.jpg

I now understand what you mean, honstly I understand how true and false ended up as keywords. This seems to be a “feature” (broken) and I see how it could cause confusion. Honestly I don’t see why we couldn’t add true and false to the definitions in the API. Look for it in the next version. :slight_smile:

***“easyC 4.0.2.x the Search for More Features” ***

Thanks for clearing up this issue the students and I observed and giving your attention!