Thread View: alt.msdos.programmer
1 messages
1 total messages
Started by D Venkatrangan
Tue, 21 Aug 1990 15:38
Typecasting NULL to far FULL.
Author: D Venkatrangan
Date: Tue, 21 Aug 1990 15:38
Date: Tue, 21 Aug 1990 15:38
36 lines
1616 bytes
1616 bytes
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.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads