Turbo C Problem?

Leo de Wit leo at philmds.UUCP
Tue Mar 1 21:56:40 AEST 1988


It could be that your program has not allocated enough stack space.
I myself had a similar problem using a Lattice-C compiler for the Atari-ST.
The compiler reserves some default stack space for the program to run in
(usually about 2K). You can alter it by initiating the global variable _stack,
	e.g.:

int _stack = WHAT_I_NEED;

Also the actual memory requirements for the program can be set by assigning to
an other global, _mneed:

int _mneed = ALL_I_CAN_GET; /* or something like that */

The default for the Atari is that all but 4K of the memory is taken by the
program. So if you're planning to write a shell or a make utility or whatever
program that does have to leave some memory, use this assignment.

The bomb that goes off in your program could be that by assigning to the 
structure elements (which are on the stack) you end up by writing on addresses
that have not been reserved for the stack. So the solution seems to me:
	either use something similar like the above (check your compiler!) or
don't push such large data elements on the stack (small machines, but also even
large ones generally don't like that); use static allocation for that.

                            L.J.M. de Wit



More information about the Comp.lang.c mailing list