This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: [GCC 3.2] Unexpected warning 'strchr' defined but not used
- From: Neil Booth <neil at daikokuya dot co dot uk>
- To: Sam Ravnborg <sam at ravnborg dot org>
- Cc: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 17 May 2003 21:07:13 +0100
- Subject: Re: [GCC 3.2] Unexpected warning 'strchr' defined but not used
- References: <20030517193719.GA10629@mars.ravnborg.org>
Sam Ravnborg wrote:-
> gcc emits a warning about 'strchr' being defined but not used when
> compiling the following piece of code in the linux kernel:
>
> foo.c:
> #include <linux/string.h>
> void foo(void)
> {
> strstr(NULL, "%");
> }
>
> Inspecting the .lst file I could see that gcc recognises the
> strstr with a one char string as second argument is better served with strchr.
> Therefore the static extern inline version is included.
>
> But gcc emits a warning that strchr is defined but never used in this case.
The kernel is a special case; GCC is entitled to assume the existence of
standard C library functions. You need to work around it, with
-fno-builtin perhaps.
Neil.