This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: More fortran dir warning fixes
- To: law at cygnus dot com
- Subject: Re: More fortran dir warning fixes
- From: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>
- Date: Sun, 28 Nov 1999 21:48:03 -0500 (EST)
- Cc: egcs-patches at egcs dot cygnus dot com
> From: Jeffrey A Law <law@cygnus.com>
>
> > name = bsearch ("foo", &names[0], ARRAY_SIZE (names), sizeof (names[
> > 0]),
> > - (int (*)()) strcmp);
> > + (int (*)(const void *, const void *)) strcmp);
> I get a little worried when we have to cast system level function pointers
> like this. What precisely about strcmp is causing problems?
> jeff
Well there's two things, why cast at all, and why did I add the
arguments. (I think you meant the first one, but I'll answer both.)
Regarding the first question, you need some sort of cast because the
prototype for strcmp is "int(*)(const char *, const char *)" and
bsearch is expecting const void * arguments. Gcc complains when you
pass it strcmp without any cast at all.
> warning: passing arg 5 of `bsearch' from incompatible pointer type
Regarding the second question, I added arguments to the cast because
-Wstrict-prototypes didn't like it without them.
> warning: function declaration isn't a prototype
--Kaveh
--
Kaveh R. Ghazi Engagement Manager / Project Services
ghazi@caip.rutgers.edu Qwest Internet Solutions