Versions Compared

Key

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

...

In this noncompliant code example, EOF is defined as -1. The macro replacement list consists of a unary negation operator ' - ' followed by an integer literal ' 1'.

Code Block
bgColor#FFcccc
#define EOF -1
/* ... */
if (getchar() EOF) {
   /* ... */
}

...

Code Block
bgColor#ccccff
enum { EOF = -1 };
/* ... */
if (getchar() != EOF) {
   /* ... */
}

Exceptions

PRE02-EX1. : A macro that expands to a single identifier or function call is not affected by the precedence of any operators in the surrounding expression, so its replacement list need not be parenthesized.

...