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) );
This is a discussion on Preprocessor directives within the C Programming forums, part of the General Programming Boards category; hey guys i came across this Code: #define LCD_E(x) ((x) ? (IOSET1 = PIN_E) : (IOCLR1 = PIN_E) ); i ...
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.
C + C++ Compiler: MinGW port of GCC
Version Control System: Bazaar
Look up a C++ Reference and learn How To Ask Questions The Smart Way
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.