This is the mail archive of the gcc-patches@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]

Re: More fortran dir warning fixes



  In message <199911290248.VAA27925@caip.rutgers.edu>you write:
  >  > 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 pointe
  > rs
  >  > 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.)
Yes, I meant the first.

  > 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.
  > 
Sigh.  Aren't void * and char * supposed to be interchangeable for this
kind of stuff?  No?  How lame.

jeff


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