First, the good news - Watcom includes code at the start and end of each 
function to detect stack overflows.  It is a lot easier to debug code 
when you know what the root cause of the problem is. If the stack 
overflow were to happen and remain silent, you could have all sorts of 
strange behavior.

- Don't allocate large structures on the stack.  That is the first 
problem.  8KB for a stack object is pretty large.  Use malloc or other 
dynamic memory allocation instead.

- If you need a large stack because you have lots of functions calling 
each other or are writing recursive code, there is a linker option to 
increase the size of the stack.  The default size is small.  I usually 
use "stack=4096" on my mTCP apps to increase the size to something more 
reasonable for my code.  You can figure out the correct value for your 
code by trial and error or by doing a careful analysis of your code.


LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
Freedos-user mailing list

Reply via email to