hey guys i came across this
i know that it is macro expansion but wat does the expression in the brackets mean?Code:#define LCD_E(x) ((x) ? (IOSET1 = PIN_E) : (IOCLR1 = PIN_E) );
hey guys i came across this
i know that it is macro expansion but wat does the expression in the brackets mean?Code:#define LCD_E(x) ((x) ? (IOSET1 = PIN_E) : (IOCLR1 = PIN_E) );
It is the ternary operator. If x evaluates to true, the result of the operation is (IOSET1 = PIN_E), otherwise it is (IOCLR1 = PIN_E). Incidentally, the semi-colon at the end of the macro looks like it should not be there.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
On a completely unrelated note:
[] = Brackets
{} = Braces
() = Parens (parentheses)
As it is, one can figure out what you meant, but saying "brackets" when you mean "parens" can be confusing if both are present in the expression.
My best code is written with the delete key.