Compiler-heap woes....

Kaleb Keithley kaleb at mars.jpl.nasa.gov
Thu Dec 28 09:17:50 AEST 1989


In article <101850003 at hpcvlx.cv.hp.com> billf at hpcvlx.cv.hp.com (Bill F. Faus) writes:
>I am attempting to compile in a lot of literal text and hex info
>into a Microsoft 5.1 C program.  The compiler seems to choke after
>about 40K of literal info:
>
>    char *ptr[] = {"string-1", "string-2", ..., "string-1000"};
>

I'm in the wrong building to double check the books, but, since Intel segmented
architecture severely limits any structure to 64K, and MSC5.1 is probably trying
to put all your strings in one segment, plus other runtime string literals, and
your stack...

MSC memory model looks something like this...

                ----------------- 
                |  code         | segments 1..n
                -----------------
                |  data         |  \
                -----------------   \
                |  near heap    |    } 1 segment on small (default) model
                -----------------   /
                |  stack        |  /
                -----------------
                |  far heap     |
                -----------------

Only work around that I know of is to use the large memory model, compile all
your string literals in a separate module, declare them extern in all the other
modules, and let the linker do its' thing...

Or try whichever of the mid-sized memory models that allows unlimited data, I
can never remember whether it's compact or medium;  you'll still want to 
have the strings in a separate module and link it.
Chewey, get us outta here!
                 
kaleb at mars.jpl.nasa.gov             (818)354-8771
Kaleb Keithley



More information about the Comp.lang.c mailing list