Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uflorida!haven!aplcen!jhunix!c08_d103 From: c08_d103@jhunix.HCF.JHU.EDU (Ex-God) Newsgroups: comp.lang.c Subject: Re: %p and different pointer representations Message-ID: <928@jhunix.HCF.JHU.EDU> Date: 1 Mar 89 21:49:49 GMT References: <9382@bloom-beacon.MIT.EDU> <1089@vicorp.UUCP> <234@mstan.Morgan.COM> <16112@mimsy.UUCP> <9453@bloom-beacon.MIT.EDU> <1890@dataio.Data-IO.COM> Reply-To: ins_balb@jhunix.UUCP (Andy Matter) Organization: The Johns Hopkins University - HCF Lines: 33 I need a few things clarified; I don't have a copy of the standard, and a few people have said mutually contradictory things. So tell me if the following is right: Any object or incomplete pointer fits in (void *). Any object or inconplete pointer fits in (char *). Any function pointer fits in any other function pointer. Function pointers do not have to fit into (void *) (or vice-versa). 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). I can see one problem with this solution -- if, for example, an implementation stored functions in one area and objects in another and there was no pointer type that could point to either. I suppose you could use a union or something.... I guess the best solution would have been to continue using char * as a generic object pointer, to make all function pointer the same size, and to make void * big enough to hold either. Someone should have thought of that earlier, I guess.... -- Andrew Barnert (Andy Social/Andy Christ/Andy Matter/ex-God) ins_balb@jhunix/ins_balb@jhuvms/c08_d103@jhunix The opinions expressed in this message are yours. "If you can't stand the Big Chill, burn down the freezer." -- Jello Biafra