[GCC 3.2] Unexpected warning 'strchr' defined but not used

Neil Booth neil@daikokuya.co.uk
Sat May 17 20:35:00 GMT 2003


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.



More information about the Gcc-bugs mailing list