%p and different pointer representations
Chris Torek
chris at mimsy.UUCP
Sat Feb 25 07:02:55 AEST 1989
In article <234 at mstan.Morgan.COM> dff at 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 at mimsy.umd.edu Path: uunet!mimsy!chris
More information about the Comp.lang.c
mailing list