Near, far and huge pointers¶
__near, __far and __huge (also _near, _far and _huge) qualify
data as in Open Watcom and Microsoft C, in every model but tiny:
char __far *p is a far pointer, char __near *q a 16-bit pointer into
DGROUP, and int __far table[20000]; a far variable, which the small and
medium models can use for data that does not fit in DGROUP. A near pointer
converts to a far or huge one, and far and huge pointers convert to each
other; far or huge to near needs a cast, which keeps the offset. The C
library takes default pointers, so in small and medium pass far data to
your own functions, not to strlen or memcpy; the compiler expands
copies and fills of far data inline.
On functions, __far and __near choose the call, as in Open Watcom:
int __far f(int) (or int * __far g(void)) is called with CALL FAR and
returns with RETF in any model, and void (__far *p)(void) is a far
function pointer. A __near function in the medium, large or huge model is
called with a near call, so only code in the same source file can call it.
A function qualified with the model's own kind is an ordinary function;
near and far function pointers do not convert to each other. char __far
*h(void) is a near function (in small) that returns a far pointer: the
qualifier applies to what follows it.