L2002 or L4004 Mixing Memory Models Between Modules

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

The information in this article applies to:

  • 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, versions 7.0
  • Microsoft Visual C++ for Windows, versions 1.0 and 1.5

SUMMARY

An attempt to link a module that has been compiled in the small memory model with a module compiled in the medium or large memory model produces the following warning:

   L4004: possible fixup overflow at <addr> in segment <seg>

or the following error:

   L2002: fixup overflow at <addr> in segment <seg>

Normally, you should NOT link programs that contain different memory models. All modules should be compiled using the same memory model. (You can use the "near" and "far" keywords to produce mixed-model programs, but this is tricky and usually doesn't give much performance gain.)

MORE INFORMATION

If the following module, MOD1.C

   #include<stdio.h>

   void main(void);

   void main()
   {
       printf(" module 1 \n");
       mod2();
   }

is linked with the module, MOD2.C

   #include<stdio.h>
   void mod2(void);

   void mod2()
   {
       printf(" module 2 \n");
   }

in various memory models, the following results occur:

   Memory Model      Result
   ------------      ------
   MOD1  | MOD2
   ------|-----
         |
    /AS  | /AM       L2002 : fixup overflow
         |
    /AS  | /AL       L2002 : fixup overflow
         |
    /AM  | /AS       Links, hangs on run
         |
    /AM  | /AL       Executes normally
         |
    /AL  | /AS       Links, hangs on run
         |
    /AL  | /AM       Links, prints trash for MOD2 on run


Additional reference words: kbinf 6.00 6.00a 6.00ax 7.00 1.00 1.50
KBCategory: kbtool
KBSubcategory: LinkIss
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.