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) );
Printable View
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.
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.