Novice MicroSoft C5.1 question
John Baldwin
johnb at srchtec.UUCP
Wed Aug 8 06:08:21 AEST 1990
In article <440 at demott.COM> kdq at demott.COM (Kevin D. Quitt) writes:
[referring to printf() formatting in Microsoft C ver 5.10]
> MSC's %p prints the pointer in the format SSSS:OOOO (segment/offset), with
>%Np printing only the OOOO portion. Both forms expect a 32 bit pointer,
>so non-32 bit pointers must be coerced by using the far keyword.
A good way to make your code a little more portable (note the use of the
relative term as opposed to the absolute) is to encapsulate the pointer
type...
If you have some oft-included header file (call it <generic.h>), insert a
typedef such as
typedef void far * genptr;
Choose the identifier to suit yourself and your coding style... then you can
write
printf("Address of foob is [%p] \n", (genptr)&foob);
If you move to another implementation, you only have to change the typedef.
[Obviously, in this instance, you'll have to do more than that,
since there's not a '%p' format specifier in the ANSI printf()!!!
Sorry. :-/ ]
--
John T. Baldwin | johnb at srchtec.uucp
Search Technology, Inc. | johnb%srchtec.uucp at mathcs.emory.edu
standard disclaimer: | ...uunet!samsung!emory!stiatl!srchtec..
opinions and mistakes purely my own. | ...mailrus!gatech!stiatl!srchtec...
More information about the Comp.lang.c
mailing list