Versions Compared

Key

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

...

which is not the desired behavior. This example also violates PRE00-A. Prefer inline or static functions to function-like macros.

Compliant Solution

With its replacement list parenthesized, the CUBE() macro expands correctly for this type of invocation.

Code Block
bgColor#ccccff
#define CUBE(X) ((X) * (X) * (X))
int i = 3;
int a = 81 / CUBE(i);

This compliant solution violates PRE00-A. Prefer inline or static functions to function-like macros. Consequently, this solution would be better implemented as an inline function.

Non-Compliant Code Example

...