[ldns-users] Missing or incorrect prototypes
Dag-Erling Smørgrav
des at des.no
Tue Apr 9 16:39:52 UTC 2013
Willem Toorop <willem at nlnetlabs.nl> writes:
> Dag-Erling Smørgrav <des at des.no> writes:
> > It still needs a prototype:
> This helper function is not intended for use by the public. It has no
> place in the public API.
Then provide a prototype in a separate header which is only used
internally.
> > BTW, including argument names in prototypes is a bad habit - it
> > pollutes the application namespace.
> Who says so?
The C standard.
C doesn't have as many distinct name spaces as you'd like, so using a
particular identifier as an argument name in a header file restricts
what a source file that includes that header file can use that
identifier for. This is why people do stupid things like:
foo.c: int foo(int a, int b) { /* ... */ }
foo.h: int foo(int _a, int _b);
so foo.h won't "steal" a and b from the application, but this just
replaces one error with another (_a and _b are in a namespace which is
reserved for the implementation). It is better to just leave out the
name entirely.
> It has documentational value. It indicates the meaning of what is
> expected.
1) You already have comments documenting the arguments.
2) Your users shouldn't have to refer to the headers anyway. That's
what man pages are for.
DES
--
Dag-Erling Smørgrav - des at des.no
More information about the ldns-users
mailing list