[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug-gnulib] Re: [PATCH]: fix warning in the hash module
From: |
Bruno Haible |
Subject: |
[bug-gnulib] Re: [PATCH]: fix warning in the hash module |
Date: |
Fri, 20 May 2005 13:53:26 +0200 |
User-agent: |
KMail/1.5 |
Jim Meyering wrote:
> What if we were to convert to the const-less signatures you prefer,
> and then an application wants to call hash_insert with a variable of
> type `char const *'? -- of course, the key-freer function is NULL
> in that case. Then, it's not just the relatively obscure -Wcast-qual
> that evokes a warning, but instead it's gcc's more commonly used
> -W option:
>
> warning: passing argument 2 of 'hash_insert' discards qualifiers
> from pointer target type
>
> And since there are applications that do precisely that, I prefer
> to incur a little bit of technically unclean code under the covers
> than to require every such caller to cast-away their perfectly
> reasonable `const' attributes.
Agreed. It's more important for an interface (hash.h) to be usable without
warnings in the common cases, than for its implementation (hash.c) to be
without warnings. Here the common cases are:
1) All keys are 'const something *'.
2) All keys are 'something *'.
Because of 1, the argument type must be 'const void *'.
Because of 2, the return type of hash_lookup() must be 'void *'.
Same reasoning as for strchr(), memchr(), etc.
Bruno
- [bug-gnulib] [PATCH]: fix warning in the hash module, Yoann Vandoorselaere, 2005/05/17
- [bug-gnulib] Re: [PATCH]: fix warning in the hash module, Jim Meyering, 2005/05/17
- [bug-gnulib] Re: [PATCH]: fix warning in the hash module, Yoann Vandoorselaere, 2005/05/17
- [bug-gnulib] Re: [PATCH]: fix warning in the hash module, Ian Abbott, 2005/05/18
- Re: [bug-gnulib] Re: [PATCH]: fix warning in the hash module, Yoann Vandoorselaere, 2005/05/18
- [bug-gnulib] Re: [PATCH]: fix warning in the hash module, Ian Abbott, 2005/05/19
- [bug-gnulib] Re: [PATCH]: fix warning in the hash module, Yoann Vandoorselaere, 2005/05/19
- [bug-gnulib] Re: [PATCH]: fix warning in the hash module, Ian Abbott, 2005/05/19
- [bug-gnulib] Re: [PATCH]: fix warning in the hash module, Yoann Vandoorselaere, 2005/05/19