This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [rfa] Change lbasename() to return ``const char *''
- To: Andrew Cagney <ac131313 at cygnus dot com>
- Subject: Re: [rfa] Change lbasename() to return ``const char *''
- From: Fergus Henderson <fjh at cs dot mu dot oz dot au>
- Date: Wed, 8 Aug 2001 22:09:10 +1000
- Cc: gcc-patches at gcc dot gnu dot org, gdb-patches at sources dot redhat dot com, binutils at sources dot redhat dot com
- References: <3B709080.7040508@cygnus.com>
On 07-Aug-2001, Andrew Cagney <ac131313@cygnus.com> wrote:
> The attached patch changes the liberty function lbasename() so that it
> returns ``const char *''.
Why? That will lead to the need for casts in the callers. Why not just
put the cast in lbasename(), like is done for strchr() in the C standard?
lbasename() is const-polymorphic, i.e. the return value should be
a const pointer iff the argument is a const pointer.
C doesn't have any good way to express the type of const-polymorphic routines.
Unless you duplicate the code in two functions, one for const pointers and one
for non-const pointers, some casting will be required.
--
Fergus Henderson <fjh@cs.mu.oz.au> | "I have always known that the pursuit
The University of Melbourne | of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.