[comp.std.c] Pointer to void

rickc@agora.UUCP (Rick Coates) (07/22/88)

I did not intend to appeal to authority with my comment about
Microsoft C (_especially_ Microsoft) in my previous posting - it
was just a comment.

I don't have a copy of the dpANSI standard - but I do
have the second edition of K&R. On page 199, they discuss void pointers
with no mention of restrictions about pointer to functions.
(Also a comment - I am _not_ saying that K&R are the authority).

Seems (offhand - I haven't spent years of my life thinking about this
issue) that a void pointer should be for any pointer, not just data.

Can someone elaborate on why ANSI does not allow void pointers for
functions?

Rick Coates

tektronix!reed!percival!agora!rickc
OR
tektronix!sequent!islabs!ateq!rick

bill@proxftl.UUCP (T. William Wells) (07/24/88)

In article <1066@agora.UUCP> rickc@agora.UUCP (Rick Coates) writes:
: Can someone elaborate on why ANSI does not allow void pointers for
: functions?

The basic reason is that data pointers and function pointers can
have very different sizes.  I have heard claims for function
pointers with 7x and 9x data pointer sizes.  (Anybody want to say
which machines?) And, of course, there is the IBM-PC, where
certain programming models may use far function pointers and near
data pointers (or v.v.), a difference of 2x.

Given this, it is desirable to have generic function and data
pointers not be commensurable in order to save memory for the
shorter data type.  Of course, this can be taken to the extreme
where there are no generic pointer types.

For one who needs a data structure which can hold both types of
pointers, use a union.