Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!hp-pcd!hpspkla!dubner From: dubner@hpspkla.spk.hp.com (Joe Dubner) Newsgroups: comp.lang.c Subject: Re: _stklen in Turbo C Message-ID: <3920002@hpspkla.spk.hp.com> Date: 6 Feb 91 15:59:35 GMT References: <1921@ruunsa.fys.ruu.nl> Organization: Hewlett Packard Company, Spokane, Wa. Lines: 41 > 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@hpspkla.HP.COM | TAFC-34 M.S. 2I | (509) 921-3514 | Spokane, WA 99220 USA | --------------------------------------------------------------------------