_stklen in Turbo C
Joe Dubner
dubner at hpspkla.spk.hp.com
Thu Feb 7 02:59:35 AEST 1991
> For a variety of reasons I'd like to be able to compile (on a DOS machine
> with Turbo C) with a stack that is larger than the usual 4kB. The manual
> (yes, I *have* read the FM) says I should simply set _stklen (defined in
> dos.h) to the desired value. I just can't find out where. If I put e.g.
>
> _stklen = 10000;
>
> at the start of main (), nothing happens, i.e. when I deliberately cause
> a stack overflow by some silly recursion, the number of times my
> stack-consuming function can call itself before triggering the `Stack
> overflow!' run-time error is always the same. (I can even make _stklen 0
> if I like.) Actually, I don't understand how a program would be able to
> change its own stack size at run time. Is this really what happens (or,
> in my case, doesn't happen)? Who has a working example of how to do this?
Chalk this up to a quirk (bug? Or design decision?) in TC++. (I assume
you're using it -- I don't know about TC 2.0). _stklen needs to be set
_outside_ of any function and _before_ any code is generated (before
your first linked function) if stack overflow checking is enabled (and I
assume it is in your case, judging by the 'Stack Overflow!' message).
For example:
extern unsigned _stklen = 16 * 1024;
main()
{}
other_functions()
{}
I'll bet this fixes it for you!
Joe
--------------------------------------------------------------------------
Joe Dubner K7JD | Hewlett Packard Company | dubner at hpspkla.HP.COM
| TAFC-34 M.S. 2I | (509) 921-3514
| Spokane, WA 99220 USA |
--------------------------------------------------------------------------
More information about the Comp.lang.c
mailing list