DOC: Use of _far Keyword in Tiny Programs

ID: Q66104

6.00 6.00a 6.00ax 7.00 | 1.00

MS-DOS                 | WINDOWS
kbprg kbdocerr

The information in this article applies to:

SUMMARY

A tiny memory model program cannot have _far code. The following documentation, taken from online help in Microsoft C versions 6.0, 6.0a, 6.0ax, 7.0, and Visual C++ version 1.0, is incorrect because it is not possible to use the _far keyword with code addresses or static data addresses in a tiny program. It is also not possible to use the _huge keyword with static data addresses.

MORE INFORMATION

The _far keyword does override the near addresses correctly, but the linker will generate the following error message because a .COM file cannot have segment references:

   LINK : fatal error L1127: far segment references not allowed with
   /TINY

Selecting DOS COM from initial build options in PWB and not placing a /AT in the additional build options will also cause the above error.

You can use _far and _huge keywords to create pointers for use with dynamic memory or to set up pointers with absolute addresses, such as a pointer to video memory. This is because these pointers do not have segment values that depend on where the program is loaded in memory. An .EXE file contains a table of all segment references that are made by the program in its header. When the program is loaded, all segment values in the table are adjusted for the programs load location. Because .COM files do not have this header information, they cannot contain segment references.

No Microsoft graphics library routines can be used when generating .COM files because they are all compiled as far calls.

Additional reference words: 6.00 6.00a 6.00ax 7.00 1.00 KBCategory: kbprg kbdocerr KBSubcategory: CLngIss Keywords : kb16bitonly

Last Reviewed: November 12, 1998