This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PATCH Replace index() with strchr() in read-rtl.c
"Joseph S. Myers" <jsm@polyomino.org.uk> writes:
> On Sun, 12 Sep 2004, Aaron W. LaFramboise wrote:
>
>> Not all platforms (such as MinGW) have index() used in read-rtl.c,
>> causing a bootstrap failure on these targets. index() is not in
>> Standard C, and POSIX recommends that strchr() (which is in Standard C)
>> be used instead.
>
> As do the GCC Coding Conventions - but the identifier "index" is too
> widely used for other things to poison it in order to prevent this
> function being used by accident.
>
> I thought I'd got rid of all calls to index() nearly four years ago
> <http://gcc.gnu.org/ml/gcc-patches/2000-11/msg00038.html>; I wasn't
> expecting someone to add some again now (the ones in question seem to be
> new from August).
Now that we can count on C90 macro semantics, I wonder if
#undef index
#define index(a,b,c) use_strchr_not_index(a,b,c)
#undef rindex
#define rindex(a,b,c) use_strrchr_not_rindex(a,b,c)
at the end of system.h might be appropriate. (The only risk I see is
from system headers using index() behind our backs.)
zw