This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

idea for new function attribute ?



 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]