Emmanuel Delahaye said:
That said, IMO, it would be nuts to not to have names in the
prototypes, or names different than the ones of the definition, for
obvious clarity and self documenting reason.
There are sometimes good (in my opinion) reasons to have
different names in prototypes and definitions, or to omit
parameter names from prototypes. In public header files, for
example, it is necessary to give parameter names in prototypes
the same prefix that other identifiers in the library use;
otherwise a stray macro can wreak havoc. That means that it's
easier not to use names at all. Indeed, fairly often the
function name and the parameter types make it obvious how the
arguments will be used. How much more do you think you would
learn from the following prototype if I added parameter names?
void copy_bytes (void *, const void *, size_t);
Another case where I might use different names is in functions
where the first action is to convert an argument to a different
pointer type, as in a callback function passed to bsearch() or
qsort():
int compare_foos (const void *a, const void *b);
....
int compare_foos (const void *a_, const void *b_)
{
const foo *a = a_;
const foo *b = b_;
return a->key < b->key ? -1 : a->key > b->key;
}
The trailing underscore is my own personal convention for this
kind of thing. But in my opinion it would be equally reasonable
to just leave off the name entirely in the prototype.
(I'm aware that my definition here includes a prototype. When I
say "prototype" in this article I mean a prototype separate from
a definition.)