Question 13: Function prototypes in C [6]

Function prototypes are used as a form of forward declaration - identifying the profile of a function for the compiler with the implication that the actual implementation will be provided later in the source code.

In early versions of C, the prototype only needed to specify the name of the function - not the parameter list or return type. For example:

#include <stdio.h>

min();

main() {
   printf("%d\n", min(5, 3, 6));
   printf("%d\n", min(1, 4, 2));
   printf("%d\n", min(0, 2, 7));
}

min(int a, int b, int c)
{
   return (a < b) ?
      ((a < c) ? a : c) : ((b < c) ? b : c);
}

(i) Discuss the implications with respect to compile-time error checking.

(ii) Discuss the implications with respect to backwards compatibility for modern C compilers.