Kyle R . Burton on Mon, 13 May 2002 16:49:37 -0400


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] Mac OS/X, Darwin and Opensource software...


> >   localealias.c:355: void value not ignored as it ought to be
> 
> Sounds like a dumb error output rather than a dumb memcpy()
> prototype. (Unless... is this the libc memcpy() or the kernel
> memcpy()? The kernel might have good reason to have a different
> prototype based on the MACH-ness of Darwin.)

Should be the libc memcpy (glibc).  This is a very simple user space program.

  void foo()
  {
  }

  void* bar()
  {
    return (void*)"bar";
  }
  
  int main( int argc, char** argv )
  {
    char*p;
    p = foo(); /* generates the error */
    p = bar();
    return 0;
  }

When I compile that with gcc, I get the error for [p = foo();], and
even if I compile with [gcc -Wall], I don't get an error or warning
for [p = bar();] (though I would have expected to at least get a 
type cast warning).

> What's the C compiler involved here?

gcc

> > Which leads me to beleive that memcpy is prototyped as:
> 
> Doubtful. But possible.

What else is possible of generating the error: "void value not ignored as 
it ought to be"?  The only thing I know of (or can think of) is trying to 
assign a void function to a varaiable.
  
> gcc accepts a lot of things that are not, properly ANSI C. That
> doesn't make them any less Wrong.

I'm a bit fuzzy about what gcc is allowing to happen that is incorrect, or
non-ANSI C in this case.

One of the things I really like about gcc is that it was typicly much better
at reporting questionable behavior than other compilers.  It was the first
compiler I'd used that knew how to report on errors for fprintf format 
strings and the associated arguments (neither Sun's cc or HP's cc did 
that when I was forced to use them).

Kyle


-- 

------------------------------------------------------------------------------
Wisdom and Compassion are inseparable.
        -- Christmas Humphreys
mortis@voicenet.com                            http://www.voicenet.com/~mortis
------------------------------------------------------------------------------

______________________________________________________________________
Philadelphia Linux Users Group       -      http://www.phillylinux.org
Announcements-http://lists.phillylinux.org/mail/listinfo/plug-announce
General Discussion  -  http://lists.phillylinux.org/mail/listinfo/plug