[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: Avi Kivity
Subject: Re: [Qemu-devel] [RFC, PATCH] Add -Wstrict-prototypes, maybe later -Wmissing-prototypes
Date: Mon, 11 Aug 2008 19:38:42 +0300
User-agent: Thunderbird (X11/20080723)

Anthony Liguori wrote:

You could just switch void (*handler)() to void *handler.

Function pointers might be wider than data pointers.

On what platforms? void (*)() was deprecated as a generic function pointer. IIUC, there is no replacement and the rationale for that is that the vast majority of people can just use 'void *'. The general technique is discouraged though.

Segmented x86. You have function pointers consisting of a segment:offset, and data pointers consisting of an offset into the implied data segment. This was one out of five available data models.

As Paul mentioned, no modern machine does that anymore, but the distinction lives on in the standard.

Looking at the usage, though, it looks like the best thing is to have a

 void (*handler)(const char **args)

So we pass the array of arguments (could be zero length) to the handler.

Yeah, it uglifies things quite a bit though. You lose all of the nice parsing and lack of casting.

You lose the switch(nb_args) in monitor_handle_command() so it comes out even. You don't need to cast anything -- though you do need to change all the callbacks to accept an argument array.

error compiling committee.c: too many arguments to function

reply via email to

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