A special calling convention is specified for the __far keyword. The __far keyword is specified in front of the function identifier:
void __far f(void);
If the function returns a pointer, the __far keyword must be written in front of the first asterisk ( *).
int __far *f(void);
It must, however, be after the int and not before it.
For function pointers, many backends assume that the __far function pointer is pointing to functions with the __far calling convention, even if the calling convention was not specified. Moreover, most backends do not support different function pointer sizes in one compilation unit. The function pointer size is then dependent only upon the memory model.
| Declaration | Allowed | Type Description |
|---|---|---|
| int __far f(); | OK | __far function returning an int |
| __far int f(); | error | |
| __far f(); | OK | __far function returning an int |
| int __far *f(); | OK | __far function returning a pointer to int |
| int * __far f(); | OK | function returning a __far pointer to int |
| __far int * f(); | error | |
| int __far * __far f(); | OK | __far function returning a __far pointer to int |
| int __far i; | OK | global __far object |
| int __far *i; | OK | pointer to a __far object |
| int * __far i; | OK | __far pointer to int |
| int __far * __far i; | OK | __far pointer to a __far object |
| __far int *i; | OK | pointer to a __far integer |
| int *__far (* __far f)(void) | OK | __far pointer to function returning a __far pointer to int |
| void * __far (* f)(void) | OK | pointer to function returning a __far pointer to void |
| void __far * (* f)(void) | OK | pointer to __far function returning a pointer to void |