Microsoft C far pointer dereferencing

michael k finegan mfinegan at uceng.UC.EDU
Fri Aug 17 07:30:04 AEST 1990


julian at uhccux.uhcc.Hawaii.Edu (Julian Cowley) writes:

>Ok, I've read the articles concerning the use of (void far *) in
>Microsoft C, but I still can't figure out why the pointer in
>following piece of code won't dereference.  What I'm trying to
>do is access the MCGA screen at A000:0000, in case there is a
>better way to do this...

>PutPixel (int x, int y, unsigned char c)
>{
>  unsigned char far *mem;

>  FP_SEG (mem) = 0xa000;
>  FP_OFF (mem) = 320 * y + x;

>  *mem = c;		/* <-- this line gives a run-time error */
>}

If you look at the manual page again, it says the use of FP_*** is library
(i.e. memory model) dependent. For small and medium models, these macros
will only work if the pointer mem is in the default data segment. You have
it on the stack (subroutine automatic variables) - is that the problem ?

						- Mike
						  mfinegan at uceng.UC.EDU



More information about the Comp.lang.c mailing list