C/C++ Compiler (cl.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.
Overriding Default Addressing
◄Up► ◄Contents► ◄Index► ◄Back►
─────C/C++ Compiler─────────────────────────────────────────────────────────
You can override the default addressing convention for a given
function, function call, or data reference by declaring code or
data items as near, far, huge, or based. You don't need to change
the addressing conventions for the program as a whole. Simply use
the __near, __far, __huge, or __based keywords.
__near Keyword
■ Data resides in the default data segment. It is referenced
with 16-bit addresses (pointers to data are 16 bits).
■ Function is assumed to be in the current code segment. It is
referenced with 16-bit addresses (pointers to functions are
16 bits) and called with short call.
■ Variables declared with the __near keyword use 16-bit pointer
arithmetic.
__far Keyword
■ Data can be anywhere in memory. It is not assumed to reside
in the current data segment. Data items are assumed not to
cross segment boundaries and are referenced with 32-bit
addresses (pointers to data are 32 bits).
■ Function is not assumed to be in the current code segment. It
is referenced with 32-bit addresses (pointers to functions
are 32 bits) and called with far call.
■ Variables declared with the __far keyword use 16-bit pointer
arithmetic.
__huge Keyword
■ Data can be anywhere in memory. It is not assumed to reside
in the current data segment. Individual arrays can exceed 64K
in size. Data is referenced with 32-bit addresses (pointers
to data are 32 bits).
■ The __huge keyword is not applicable to functions.
■ Variables declared with the __huge keyword use 32-bit pointer
arithmetic for data (same restrictions as for __huge array).
__based Keyword
■ Data can be anywhere in memory. It is not assumed to reside
in the current data segment. The range of 32-bit addresses is
provided by 16-bit addresses plus a known base.
■ Variables declared with the __based keyword use 16-bit pointer
arithmetic for data.
See also: ◄Library Support for Keywords►
-♦-