Path: utzoo!mnetor!tmsoft!torsqnt!lethe!yunexus!ists!helios.physics.utoronto.ca!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!mcsun!hp4nl!ruuinf!ruunsa!boogaard From: boogaard@ruunsa.fys.ruu.nl (Martin vdBoogaard) Newsgroups: comp.lang.c Subject: Re: _stklen in Turbo C Keywords: stack, DOS, Turbo, Borland Message-ID: <1933@ruunsa.fys.ruu.nl> Date: 8 Feb 91 11:15:00 GMT References: <1921@ruunsa.fys.ruu.nl> Organization: University of Utrecht, Dept. of Physics Lines: 34 Thanks to all the people who responded to my question about the use of _stklen in Turbo C. As was pointed out, statements like extern unsigned _stklen = 10000; have to be made outside any function. And indeed, all this could have been found in the HELPME!.DOC file. Having been told how to do the trick, I have tried to detect the influence of assignements like this. However, nothing happened, because I was using the medium memory model. This brings up a second question, i.e. when does Turbo C (with the -N compiler option) signal a stack overflow? Let's call the current size of the heap H and the size of the static data D. Stack overflow is signaled by your program when the current stack size exceeds S_max. It seems to me that in Turbo C's small-data memory models (tiny, small, medium) at any time we simply have S_max = 64kB - H - D, in other words: the value of _stklen is in this case completely irrelevant. In the large-data memory models (compact, large, huge) the role of _stklen is what you expect it to be: S_max = _stklen. All this is, as far as I know, not in Borland's manuals. The section on the -N compiler option hails the stack overflow detection as `a real lifesaver', but there is no adequate info on what to do about stack overflow (except simplifying your code and minimizing the use of local variables) and what the choice of the memory model has got to do with this. Is there any reason why we're not able to simply tell TLINK how large we want the stack to be? Martin J. van den Boogaard | Dept. of Atomic & Interface Physics | Debye Institute--Utrecht University boogaard@fys.ruu.nl | P.O. Box 80.000, NL-3508 TA Utrecht boogaard@hutruu51.bitnet | the Netherlands, +31 30 532904 ------------------------------------------------------------------------