%p and different pointer representations
T. William Wells
bill at twwells.uucp
Sat Mar 4 11:40:57 AEST 1989
In article <9765 at smoke.BRL.MIL> gwyn at brl.arpa (Doug Gwyn (VLD/VMB) <gwyn>) writes:
: >Also, how's this for a solution:
: >#if sizeof (void *) > sizeof (void (*)())
: >#define generic_ptr (void *)
: >#else
: >#define generic_ptr (void (*)())
: >#endif
: >Then use generic_ptr instead of void *, and any pointer type
: >(including pointers to functions) will fit (as long as you remember to
: >cast everything you assign).
:
: Won't work. There is no guarantee that an object pointer can be
: converted to a function pointer or vice-versa.
Also, the sizeofs don't work in #ifs. Not according to the dpANS, nor
in many existing compilers.
---
Bill
{ uunet | novavax } !twwells!bill
(BTW, I'm going to be looking for a new job sometime in the next
few months. If you know of a good one, do send me e-mail.)
More information about the Comp.lang.c
mailing list