__far

The __far keyword specifies that a name is to have 32-bit addressing. For functions, this 32-bit address contains the segment and offset of the called function; for objects, it contains the segment and offset of the object.

Functions in the same compilation unit reside in the same segment unless the alloc_text, code_seg, or same_seg pragmas are used, or unless the function is declared as based. The default naming convention for functions specified as __far is source-filename_TEXT. The default naming convention for objects specified as __far is source-filename_DATA.

Class-type objects declared as far have:

Far addressing for member data.

Far this pointer.

Function calling determined by the compilation options.

Limit on object or array size; the practical limit on the size of a single far object is 64K–data-threshold-size. The data-threshold-size defaults to 32,767, but it can be set using the /Gt compilation option.

Objects declared as __far must reside within the segment in which they start. Therefore, they must be smaller than 64K. This restriction allows pointer arithmetic to be done on 16-bit values while still retaining the ability to address data in multiple segments.

The alloc_text pragma affects where segment functions declared as __far reside; the same_seg pragma affects assumptions the compiler makes regarding where segment functions and objects declared as __far reside. For more information about the alloc_text and same_seg pragmas, see “Pragma Directives” in Chapter 13, on topic .

32-Bit Specific

The __far keyword is not supported in 32-bit compilations.¨