This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
idea for new function attribute ?
- To: egcs at cygnus dot com
- Subject: idea for new function attribute ?
- From: James A <jamesa at demon dot net>
- Date: 03 Jun 1998 15:45:26 +0100
- Reply-To: <jamesa at demon dot net>
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)));
This would propagate the constness of the first parameter to the
return value. Then (with -Wwrite-strings on)...
char *abcd = my_strnchr("abcd", 4, 'a');
would generate a warning but...
char abcd[] = "abcd";
*my_strnchr(abcd, 4, 'b') = 0;
Would not.
I've had a quick look at egcs-1.0.3a and I think I can do the patch
but if there is a better way of doing it (or it's not worth doing at
all) etc. don't hesitate to correct me.
--
# James Antill -- jamesa@demon.net
:0:
* ^From: .*jamesa@demon.net
/dev/null