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 mailing list bug-gnulib@gnu.org http://lists.gnu.org/mailman/listinfo/bug-gnulib