CC> How do you increase the stack size using BC++4.51 for DOS and 16
CC> bit targets?
CC> The only thing I've found is for 32bit targets and just stack
CC> checking under debugging.
Under Turbo C++ 3.00:
Q. How do I change the stack size?
A. The size of the stack of a Turbo C++ program is determined at
run time by the global variable _stklen. To change the size
to, for example, 10,000 bytes, include the following line in
your program:
extern unsigned _stklen = 10000;
This statement must not be inside any function definition.
The default stack size is 4,096 bytes (4K).
Q. I'm getting a 'Stack Overflow!' message when I run my program.
How can I work around this?
A. You may increase the stack size by following the procedure above. Stack
overflows are usually caused by a large amount of local data or
recursive functions. You can decrease the amount of stack space
used by declaring your local variables static:
int main(void) int main(void)
{ {
char x[5000]; --> static char x[5000];
: :
} }
Of course, you should be aware that there are other effects
that the "static" keyword has, as applied here.
Sincerely,
Anthony Tibbs
... "All the time she's smiling, you know you'll be on your knees tomorrow
___ Blue Wave/DOS v2.30 [NR]
--- Maximus 3.01
---------------
* Origin: World of Power BBS * Private * Ottawa, ON (1:163/215.38)
|