View Single Post
  #4   Spotlight this post!  
Unread 22-01-2004, 10:00
Guest
 
Posts: n/a
Re: bool Variables, Autonomous Mode

By default, if you use a char to store "boolean" values, 0 is false and everything else is true. However if you have:
Code:
char boolVal=0;
boolVal=!boolVal;
// boolVal is now 255
Hence, you probably want to #define the following:
Code:
// Put this in a header file that every .c file accesses
typedef char bool;
#define true (char)(255)
#define false (char)(0)
Be sure to watch out for automatic cast of anything below above -1 and below 256 to an unsigned char.