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]

Re: idea for new function attribute ?


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   `------------------------


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