Xref: utzoo alt.msdos.programmer:2059 comp.os.msdos.programmer:599 comp.lang.c:31278 Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!umich!yale!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!sdd.hp.com!decwrl!uunet!matrix!venkat From: venkat@matrix.UUCP (D Venkatrangan) Newsgroups: alt.msdos.programmer,comp.os.msdos.programmer,comp.lang.c Subject: Typecasting NULL to far FULL. Message-ID: <164@matrix.UUCP> Date: 21 Aug 90 15:38:23 GMT Distribution: na Organization: Matrix Computer Systems, Nashua, NH Lines: 36 Greetings, programmers. I have run into what appears to be a minor problem, but in reality is turning into a nightmare... I am writing a library containing interface routines into a driver. These interface routines are compiled into small, medium and large model libraries. Since the driver code has its own data segment, these interface routines convert a model-dependent pointer of the linked program into a far pointer and then call the driver. The specific problem is with pointers that are NULL. If I have char *p; char far *farp; and if p is NULL, the following assignment farp = (char far *)p; produces a farp with FP_SEG(farp) == current DS and FP_OFF(farp) == 0. Instead, I want FP_SEG(farp) == 0 and FP_OFF(farp) == 0, because the driver checks for a (long)0 for NULL pointer and a DS:0 will not be considered to be NULL by the driver. Of course, the following assignement produces the correct result. farp = p ? (char far *)p : (char far *)0L; But since this is being done many times over, I am interested in a simpler solution that will avoid the code overhead. I am using Microsoft C 5.1 Thanks.