C Standard - Is a function definition a function prototype?
The standard (latest version : WG14/N1256) says (6.2.1 §2) :
A function prototype is a declaration of a function that declares the types of its parameters.
In the vicinity of this statement, we also find evidence that an identifier declaration consist of a declarator or a type specifier (§4) :
Every other identifier has scope determined by the placement of its declaration (in a declarator or type specifier).
So it would seem that knowing if a function definition is a function prototype boils down to knowing if a function definition is a declarator. Is it ?
I need a proven an开发者_开发技巧swer that is in conformance to the C standard. I don't really care about the usual meaning, or what Wikipedia or your favorite C book says.
Here is the statement in the standard that led me to think that function definitions can indeed be function prototypes (§4) :
If the declarator or type specifier that declares the identifier appears within the list of parameter declarations in a function prototype (not part of a function definition), ...
Yes, see 6.9.1 about function definitions, paragraph 7:
If the declarator includes a parameter type list, the list also specifies the types of all the parameters; such a declarator also serves as a function prototype for later calls to the same function in the same translation unit.
精彩评论