bug-hurd
[Top][All Lists]
Advanced

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

Re: kalloc.c and recent gcc's


From: Bas Wijnen
Subject: Re: kalloc.c and recent gcc's
Date: Sun, 28 Aug 2005 23:13:27 +0200
User-agent: Mutt/1.5.10i

On Sun, Aug 28, 2005 at 11:03:31PM +0200, Thomas Schwinge wrote:
> > > +
> > > +void (*__malloc_initialize_hook) (void) = (void *) init_hook;
> > 
> > Do you really need the void * cast?
> 
> The cast avoids the following warning:
> #v+
> [...]
> ../../hurd-0/mach-defpager/../serverboot/kalloc.c:43: warning: initialization 
> from incompatible pointer type
> [...]
> #v-

I think the proposed code should give a compiler error (which doesn't mean
that it does, of course).  Function pointers and data pointers are really
different types, and cannot be mixed.  They need not even be the same size.

If you really want to cast, then cast to the correct type, in this case a
function pointer (with matching arguments and return type).  However, it is
usually better to make sure the prototype of the function is correct, so you
don't need the cast.  I didn't check if that is possible at all in this case.

Thanks,
Bas

-- 
I encourage people to send encrypted e-mail (see http://www.gnupg.org).
If you have problems reading my e-mail, use a better reader.
Please send the central message of e-mails as plain text
   in the message body, not as HTML and definitely not as MS Word.
Please do not use the MS Word format for attachments either.
For more information, see http://129.125.47.90/e-mail.html

Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]