[ldns-users] Missing or incorrect prototypes

Jan Komissar (jkomissa) jkomissa at cisco.com
Tue Apr 9 20:20:48 UTC 2013


Some IDEs show the parameters of a function when you type it (see picture
from Eclipse). It is very useful to know the order and type of parameters
in the context of writing code, so you don't have to distract yourself by
looking up that information.


And, Dag-Erling, Can you show me an example (without "#define a") where
the declaration "int foo(int a);" steals "a" from the application's name
space. I wasn't able to come up with an example on my own.

Cheers,

Jan.


On 4/9/13 3:06 PM, "Paul Wouters" <paul at nohats.ca> wrote:

>On Tue, 9 Apr 2013, Dag-Erling Smørgrav wrote:
>
>> 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.
>
>Or better yet, see if you can make the function static?
>
>> 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.
>
>Interesting. I should look into this....
>
>> 2) Your users shouldn't have to refer to the headers anyway.  That's
>>   what man pages are for.
>
>If only I was allowed to delete every binary and header file that has
>no man page, or a man page refering to the info pages, or other man page
>placeholders, along with binaries that do not have -h, --help, -v,
>--version
>
>Paul
>_______________________________________________
>ldns-users mailing list
>ldns-users at open.nlnetlabs.nl
>http://open.nlnetlabs.nl/mailman/listinfo/ldns-users

-------------- next part --------------
A non-text attachment was scrubbed...
Name: default.png
Type: image/png
Size: 4264 bytes
Desc: default.png
URL: <http://lists.nlnetlabs.nl/pipermail/ldns-users/attachments/20130409/b23d41e6/attachment.png>


More information about the ldns-users mailing list