The use of prototypes enables the compiler to check the integrity of function definitions and calls. Without prototypes the compiler is not obliged
to pick up certain errors in function calls (e.g. different number of arguments from the function body, mismatch in types of arguments between call
and definition). Function interfaces have been shown to be a cause of considerable problems, and therefore this rule is considered very important.
The recommended method of implementing function prototypes for external functions is to declare the function (i.e. give the function prototype) in
a header file, and then include the header file in all those code files that need the prototype (see MISRA C 2004, Rule 8.8).
Noncompliant code example
void example() {
fun(); // Noncompliant
}
void fun() {
}
Compliant solution
void fun();
void example() {
fun();
}
void fun() {
}