Malloc Trouble with Large Memory Model

Dave Hammond daveh at marob.MASA.COM
Tue Apr 25 08:17:20 AEST 1989


In article <8596 at xanth.cs.odu.edu> kremer at cs.odu.edu (Lloyd Kremer) writes:
>In article <208 at sabin.UUCP> bjm at sabin.UUCP (Brendan J. McMahon) writes:
>>Compile Message:
>>Warning: cast of int expression to far pointer
>>Run time problems:
>>Printf(sizeof(struct labelrec)) = Some huge number 
>Apparently, code compiled in large model is attempting to use the small model
>version of malloc().  Malloc is returning a 2-byte entity which is being
>cast unsuccessfully to a 4-byte entity.  You must recompile using the large
>model version of malloc() (and all other library functions for that matter).

Using the compiler switch -M2l insures that the compiler uses the large model
library for the standard C routines.  Assuming all of the your modules have
been compiled with -Ml2, there should be no model mismatches.

If you're using an ANSI compiler, be sure the standard C library prototype
header stddef.h is included (for correct malloc prototype), otherwise try
declaring malloc() in the modules which reference it:

char *malloc();

--
Dave Hammond
daveh at marob.masa.com



More information about the Comp.lang.c mailing list