...
This CUBE() macro definition is noncompliant because it fails to parenthesize the parameter names.
| Code Block | ||||
|---|---|---|---|---|
| ||||
#define CUBE(I) (I * I * I) |
As a result, the invocation
| Code Block | ||||
|---|---|---|---|---|
| ||||
int a = 81 / CUBE(2 + 1); |
expands to
| Code Block | ||||
|---|---|---|---|---|
| ||||
int a = 81 / (2 + 1 * 2 + 1 * 2 + 1); /* evaluates to 11 */ |
...
Parenthesizing all parameter names in the CUBE() macro allows it to expand correctly (when invoked in this manner).
| Code Block | ||||
|---|---|---|---|---|
| ||||
#define CUBE(I) ( (I) * (I) * (I) ) int a = 81 / CUBE(2 + 1); |
...