[Top][All Lists]

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

Re: [Qemu-devel] [RFC, PATCH] Add -Wstrict-prototypes, maybe later -Wmis

From: Anthony Liguori
Subject: Re: [Qemu-devel] [RFC, PATCH] Add -Wstrict-prototypes, maybe later -Wmissing-prototypes
Date: Mon, 11 Aug 2008 14:22:16 -0500
User-agent: Thunderbird (X11/20080723)

Laurent Vivier wrote:

I vote for this. The other solutions do not improve type safety
(except for union) and they are more complex.

But I think to call the function you have to cast the pointer, this doesn't improve type safety too...

Right now, the monitor works by taking a generic function pointer "void (*)()" which is treated specially by the C standard (although it's now deprecated). Any function pointer can be cast to a generic function pointer. The dispatch loop basically looks like:

void dispatch(void (*func)(), int n_args, void *args)
   switch (n_args) {
   case 1:
       ((void (*)(void *))func)(args[0]); break;
   case 1:
       ((void (*)(void *, void *))func)(args[0]); break;

But this tosses a warning since void (*)() is deprecated.  So, if we use:

void dispatch(void *func, int n_args, void *args)

It'll work just like it did before.


Anthony Liguori

----------------------- Laurent Vivier ----------------------
"The best way to predict the future is to invent it."
- Alan Kay

reply via email to

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