More fortran dir warning fixes

Jeffrey A Law law@cygnus.com
Tue Nov 30 23:59:00 GMT 1999


  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



More information about the Gcc-patches mailing list