Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

PRODUCT(3+4, 5) is converted to 3+4 * 5 by the preprocessor, which the compiler intreprets as 3+(4*5) = 23. Presumably, this does not match the intended behavior of the macro which is (3+4) * 5 = 35.

Compliant

...

Solution

Code Block
#define PRODUCT(A,B) (A) * (B)
int a = PRODUCT(3+4, 5)

...