I’m working with embedded C for the first time. Although my C is rusty, I can read the code but I don’t really have a grasp on why certain lines are the way the are. For example, I want to know if a variable is true or false and send it back to another application. Rather than setting the variable to 1 or 0, the original implementor chose 0xFF.
Is he trying to set it to an address space? or else why set a boolean variable to be 255?
0xFFsets all the bits in a char.The original implementer probably decided that the standard
0and1wasn’t good enough and decided that if all bits off is false then all bits on is true.That works because in C any value other than 0 is true. Though this will set all bytes in a char, it will also work for any other variable type, since any one bit being set in a variable makes it true.