Considering the rule "The macro expansion must always be parenthesized to protect any lower-precedence operators from the surrounding expression", square(x) is replaced by (x * x) which is (3 + 4 * 3 + 4). Correct definition one must be: #define square(x) ((x) * (x))
Considering the rule "The macro expansion must always be parenthesized to protect any lower-precedence operators from the surrounding expression", square(x) is replaced by (x * x) which is (3 + 4 * 3 + 4). Correct definition one must be:
回覆刪除#define square(x) ((x) * (x))