This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: idea for new function attribute ?
- To: egcs at cygnus dot com
- Subject: Re: idea for new function attribute ?
- From: Ulrich Drepper <drepper at cygnus dot com>
- Date: 03 Jun 1998 18:03:00 -0700
- Newsgroups: cygnus.egcs
- Organization: Cygnus Solutions
- References: <8taf7uee7t.fsf.cygnus.egcs@jamesa.noc.demon.net>
- Reply-To: drepper at cygnus dot com (Ulrich Drepper)
jamesa@demon.net (James A) writes:
> Ok I've thought that it would be nice to be able to have an attribute
> for functions in gcc like the following...
>
> char *my_strnchr(const char *, size_t, char) __attribute__ ((return_const(1)));
I think that unless you have the possibilities to overload the
functions like in C++ this does not make that much sense. E.g., one
never could declare the real string function in <string.h> this way
since then it would be possible anymore to use them on non-const
strings. And if you have a function which is only used on
const-strings then it is much easier to declare the function right
away in a way that it returns a const char *.
What situation do you have in mind?
--
---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace
Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA
Cygnus Solutions `--' drepper at cygnus.com `------------------------