C Language and Libraries Help (clang.hlp) (
Table of Contents;
Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
__far16
◄Up► ◄Contents► ◄Index► ◄Back►
─────C/C++ Language─────────────────────────────────────────────────────────
Keyword: __far16
Syntax: [extern] type __far16 [pascal] declarator
Summary: Specifies code or data compiled with a 16-bit compiler.
The sole purpose of the __far16 keyword is to allow 32-bit
code to interact with existing 16-bit code. The CL386
compiler will not generate 16-bit code or 16-bit data
segments; you cannot use __far16 to define code or data.
See also: __based, __far, __near
◄Memory models►
The __far16 keyword can only modify functions, pointers to
functions, and pointers to data.
When __far16 declares a function, it is assumed to be in a 16-bit
code segment. You must declare the function as extern and pascal.
When __far16 declares a pointer to a function or a pointer to data,
the pointer is assumed to be a 16:16 pointer. References to and
arithmetic involving such a pointer will cause implicit conversion
to a 0:32 pointer.
The main reason to declare a pointer to either a function or data as
__far16 is to pass functions or data as parameters to an external
function that was compiled in a 16-bit compilation module.
Example
/* 32-Bit Module */
char __far16 *pchptr;
extern short __far16 pascal DOS16Write( short,
char __far16 *,
short,
short __far16 * );
main()
{
short cbwrite;
pchptr = "Hello World.\n";
Dos16Write( 0, pchptr, strlen( pchptr), &cbwrite );
}
Passing an object (by either value or through a pointer) to a
__far16 function can cause errors if the object crosses a 64K
boundary. Copy such objects to static objects (which are
guaranteed to not cross a 64K boundary) and pass the static
object.
The packing of a structure argument (passed either by value or
through a pointer) must match the packing required by the 16-bit
function. Also, use __far16 to declare pointers in such a structure.
See: /Zp, pack
-♦-