PRB: C4040: "Near/far/huge Ignored" Warning

Last reviewed: July 17, 1997
Article ID: Q23978
6.00 6.00a 6.00ax 7.00 | 6.00 6.00a | 1.00 1.50
MS-DOS                 | OS/2       | WINDOWS
kbtool kbprb

The information in this article applies to:

  • The Microsoft C/C++ Compiler (CL.EXE), included with:

        - Microsoft C for MS-DOS, versions 6.0, 6.0a, and 6.0ax
        - Microsoft C for OS/2, versions 6.0 and 6.0a
        - Microsoft C/C++ for MS-DOS, version 7.0
        - Microsoft Visual C++ for Windows, versions 1.0 and 1.5
    

SYMPTOMS

An attempt to declare far data in an application compiled with the small memory model fails and the compiler generates

   Warning C4040: near/far/huge ignored

CAUSE

An application compiled in the small memory model can declare far data. The warning indicates that the "far" descriptor is incorrect or unnecessary in the context in which it is used.

RESOLUTION

Modify the source code to define far or huge arrays outside a function or as a static value in a function.

MORE INFORMATION

This warning also occurs when an application declares a "char * far pvar" pointer in the body of a function. This definition defines a pointer to data (either near or far, depending on the memory model used) and places the pointer into a data segment other than the default data segment. This declaration works correctly as a global definition or as a static definition in the body of the function.

Note that "char * far pvar" is different from "char far *pvar" which declares a pointer to far data. The latter declaration creates a pointer that can point to data outside the default data segment while the pointer itself resides in the default data segment. The latter declaration is perfectly acceptable in the body of a function compiled in the small memory model.


Additional reference words: 1.00 1.50 6.00 6.00a 6.00ax 7.00 8.00 8.00c
KBCategory: kbtool kbprb
KBSubcategory: CLIss
Keywords : kb16bitonly


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 17, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.