Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uflorida!haven!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.lang.c Subject: Re: %p and different pointer representations Message-ID: <16112@mimsy.UUCP> Date: 24 Feb 89 21:02:55 GMT References: <9382@bloom-beacon.MIT.EDU> <234@mstan.Morgan.COM> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 21 In article <234@mstan.Morgan.COM> dff@Morgan.COM (Daniel F. Fisher) writes: >To what type should a pointer argument be cast when passing it to >fprintf() for printing using the %p conversion specifier? Put it this way: `%p' prints one (void *). >First Example: In an IBM-PC implementation with small-data, >large-code, the data pointers (int *), (char *), etc. are all 16 >bits., but function pointers (int (*)()), etc. are all 32 bits. >So if I wish to print a function pointer, I cannot cast it to a >data pointer without losing information. Yes. Moreover, since sizeof(void *)==sizeof(char *)==2, when you print a pointer-to-function using %p and a (void *) cast (on that machine in that model), you will lose some information. I think this is what is known as an oversight (and goes to show why standards committees should avoid inventions).... -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris