Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!mcsun!hp4nl!dutrun!duteca!kooijman From: kooijman@duteca (Richard Kooijman) Newsgroups: comp.lang.c Subject: Re: _stklen in Turbo C Keywords: stack, DOS, Turbo, Borland Message-ID: <1216@duteca.UUCP> Date: 7 Feb 91 11:08:38 GMT References: <1921@ruunsa.fys.ruu.nl> Organization: Delft University of Technology, Netherlands Lines: 30 boogaard@ruunsa.fys.ruu.nl (Martin vdBoogaard) writes: >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 Turbo C doesn't do this at run-time, maybe sort of at run-time, but it uses the value of _stklen to reserve space, which can be done at compile-time or run-time. Maybe the start-up code reserves the space, so then it may be called a run-time space allocation, but you cannot change _stklen anyfurther in your program, so then it maybe called compile-time allocation. You must declare _stklen as follows as a global (!) definition: extern unsigned _stklen = 10000; So this must go outside of main(). Richard.