Well, the full function definition,
17 18 19 20
|
int returnVal(char x)
{
return (int)x - 87;
}
|
could be placed in a completely separate source file - that might be the case in a more complex project. So the only knowledge the compiler has when the function is called at line 13, is based on the prototype.
The purpose of the prototype declaration:
int returnVal(char);
is to
1. allow the compiler to check that the function is being called with suitable parameters, and
2. to actually generate the code which calls the function and receives the returned value, if any.
In order for that to work, the parameter list in the declaration must match the parameter list when the function is called - that is the
type
of each parameter should match, or be compatible. The return type is also required for similar reasons.
After the code has been compiled, it is the job of the linker to match up each function call with the code belonging to that function. That's a separate stage and may generate its own error messages.