[comp.lang.c] Set stack size in TurboC

var@garp.East.Sun.COM (Var Garapetian, Sun-BOS Hardware [(508)671-0298]) (11/11/89)

Could someone tell me how or direct me to where in the documentation I can 
find the way to increase the "stack size" in Turbo-C?

I am not an expert in C and am using the integrated environment for my
programs. I have my compiler set to COMPACT model. A programm I am 
working on, was causing bizzare behaviour, so I turned the "Stack Overflow"
warning on. This indeed showd I was having stack problem.

I have been through the TC manuals and have found the _stklen variable which
sets the stack size, however don't know how to set it to a larger size.
If I type the following before main():
	 extern unsigned _stklen=6144;
It seems to set the stack to a larger value, but the linker gives the 
following warning:
	__stklen defined in module GPX.C is duplicated in module STKLEN

Any help will be very much appriciated...

============================================================================
Var Garapetian,                 Sun Microsystems, East-Coast Div.

UUCP:  {hplabs,ihnp4,ucbvax,decvax,seismo}!sun!vgarapetian
 or    {decvax}!eagle_snax!garp!var

ARPA:  vgarapetian@east.sun.com

GEnie: V.GARAPETIAN
============================================================================

smasters@gmuvax2.gmu.edu (Shawn Masters) (11/13/89)

You may want to try not defining it again.  Include the #include
<dos.h>, and then type `_stklen=xxxx'.  The dos.h file should 
have all the declerations taken care of for you, which means, you
just set the variable.  Normally one would think that this would just be
a linker option that you specify at link time, but all of Borland's
manuals seems to state differently.
	Using the "COMPACT" model, you can have a stack upto 64k, which
should satisfy most of your needs. 

Shawn Masters
George Mason University

SMASTERS@GMUVAX2.GMU.EDU

var@garp.East.Sun.COM (Var Garapetian, Sun-BOS Hardware [(508)671-0298]) (11/21/89)

>>Could someone tell me how or direct me to where in the documentation I can 
>>find the way to increase the "stack size" in Turbo-C?
>>I am not an expert in C and am using the integrated environment for my
>>programs. I have my compiler set to COMPACT model. A programm I am 
>>working on, was causing bizzare behaviour, so I turned the "Stack Overflow"
>>warning on. This indeed showd I was having stack problem.
>>I have been through the TC manuals and have found the _stklen variable which
>>sets the stack size, however don't know how to set it to a larger size.
>>If I type the following before main():
>>	 extern unsigned _stklen=6144;
>>It seems to set the stack to a larger value, but the linker gives the 
>>following warning:
>>	__stklen defined in module GPX.C is duplicated in module STKLEN
>>Any help will be very much appriciated...

Thanks to all of you that replied. Most replies seemed to point out that my
original approach was right, so I went back and poked a bit and found out
previous stack overflows had some how corrupted a couple of data files which
caused me to think the above didn't enlarge the stack.

To make sure, I called Borland too and they gave me the same answer.
So to sum it up:

To extend the size of stack, put the following line before main() and ignore
the linker warning!
	extern unsigned _stklen=nnnn; /* nnnn= required stack size. */

Thanks again to all those who replied.
-var.

============================================================================
Var Garapetian,                 Sun Microsystems, East-Coast Div.

UUCP:  {hplabs,ihnp4,ucbvax,decvax,seismo}!sun!vgarapetian
 or    {decvax}!eagle_snax!garp!var

INTERNET:  vgarapetian@East.Sun.Com

GEnie: V.GARAPETIAN
============================================================================