L2002 or L4004 Mixing Memory Models Between Modules

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:

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

Last Reviewed: July 18, 1997