Mullen, Patrick wrote:

> > > void pointers (vastly different than the
> > > case of above.  Above was a pointer to a function
> > > with void parameters and void return type.
> > 
> > Nope. Above was a pointer to a function with *unspecified* parameters
> > and void return type (i.e. K&R style function declaration). If you
> > want to specify that the function takes no parameters, you have to
> > explicitly specify `void' as the parameter list.
> 
> By this, do you mean the function could point to
> void func1(void);     OR
> void func2(int, int); OR
> void func3(float);
> etc. ?

Almost, but not quite. It could point to func1 and func2, but not
func3.

The reason being that in K&R C, where functions don't have prototypes,
function arguments are promoted to certain `standard' types, i.e. 
char, short, int, bitfields and enumeration types are converted to
either int or unsigned int, and float is converted to double.

Consequently, calling `(*funcpoint)(1.0)' would pass the parameter as
a double, whereas func3 expects a float. If you define func3 as

        void func3(double);

then you could assign it to funcpoint.

> Did I accidentally hit on the way to make the same
> pointer point to any function with the same return value, but
> any parameter list,

Yep. In K&R C, a function's type is determined only by its return
type, not its parameters, so all of func1/func2/func3 have type
`function returning void' in K&R C.

> or am I reading too much into what you're saying?

No.

-- 
Glynn Clements <[EMAIL PROTECTED]>

Reply via email to