What is the difference between declaration and prototype in C? In which situations they are called declarations and in which prototypes?
According to the C Standard (6.2.1 Scopes of identifiers)
- ...(A function prototype is a declaration of a function that declares the types of its parameters.)
That is a prototype provides the information about the types of the function parameters.
Consider for example
void f();
and
void f( void );
The first declaration is not a prototype because there is nothing known about the function parameters.
The second declaration is a prototype because it provides a type list of the function parameters (it is a special kind of the type list specifies that the function has no parameters).