The information in this article applies to:
SUMMARY
Far pointers to data can be used in calls to the C Run-time library
routines written using the medium model. This is often necessary
because many Windows-based applications are written using the medium model,
but must pass far data pointers to the medium model C run-time library
routines. Unless precautions are taken, passing far pointers to medium
model C Run-time routines will fail.
MORE INFORMATION
When an application is compiled using the medium memory model, the C
compiler assumes that the application will have one data segment and
multiple code segments. Because the application has only one data
segment, all pointers to data are assumed to be near pointers.
Therefore, when the compiler encounters a C Run-time function in the
source code, it automatically assumes that any pointer parameters
contain near pointers. The compiler uses the appropriate medium model
declaration for the run-time functions. This is appropriate for NEAR
data items, but many Windows API functions require or return FAR
pointers, such as GlobalLock().
the compiler will use the default declaration for the routine. That
declaration is found in the header file and resembles the following:
In this situation, the data must be in the default data segment
because the routine will use the DS register when referencing both
strings.
In the same medium model applications, if one or both of the strings are in a data segment other than the default data segment, modify the same source line as follows:
In this case, the compiler will use the following function declaration
and the application will then properly access the data in the far
segments.
NOTE: When using the same C Run-time routine in a large model application, the default function declaration will be the model-independent version. Thus, in the example above, the compiler will replace the call to strncpy() with an appropriate call to _fstrncpy(). Additional query words: 3.00 3.10
Keywords : kb16bitonly |
Last Reviewed: November 3, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |