Versions Compared

Key

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

...

Code Block
bgColor#FFCCCC
langc
int max(a, b)
int a, b;
{
  return a > b ? a : b;
}

Section Subclause 6.11.7 of the C Standard [ISO/IEC 9899:2011] states that "the use of function definitions with separate parameter identifier and declaration lists (not prototype-format parameter type and identifier declarators) is an obsolescent feature."

...

Code Block
bgColor#FFCCCC
langc
int add(int x, int y, int z) {
   return x + y + z;
}

int main(int argc, char *argv[]) {
   int (*fn_ptr) (int, int);
   int res;
   fn_ptr = add;
   res = fn_ptr(2, 3);  /* incorrectIncorrect */
   /* ... */
   return 0;
}

Compliant Solution (Function Pointers)

...

Bibliography

[ISO/IEC 9899:2011]Section Subclause 6.11.7, "Function Definitions"
[Spinellis 2006]Section 2.6.1, "Incorrect Routine or Arguments"

...