This is the mail archive of the gcc-bugs@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]
Other format: [Raw text]

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


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.


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