Microsoft C far pointer dereferencing

thomas.j.roberts tjr at cbnewsc.att.com
Tue Aug 21 00:33:39 AEST 1990


>From article <7990017 at hpopd.HP.COM>, by richardh at hpopd.HP.COM (Richard Hancock):
> / hpopd:comp.lang.c / mfinegan at uceng.UC.EDU (michael k finegan) / 10:30 pm  Aug 16, 1990 /
> 
>>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 */
>>}

In Turbo C, the FP_SEG(mem) = ...; statement gets "not an lvalue"
error. In Turbo C you should use:

	mem = MK_FP(0xA000,320*y+x);
	*mem = c;

Turbo C has the FP_SEG() and FP_OFF() macros as used above, and the
MK_FP() macto to create a far pointer; I assume Microsoft C does also,
but have no experience at all using Microsoft C.

Tom Roberts
att!ihlpl!tjrob



More information about the Comp.lang.c mailing list