Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!gem.mps.ohio-state.edu!uakari.primate.wisc.edu!uflorida!gatech!udel!new
From: new@udel.edu (Darren New)
Newsgroups: comp.sys.amiga
Subject: Re: Is she c:Stack'd
Message-ID: <620@nigel.udel.EDU>
Date: 3 Oct 89 16:51:49 GMT
References: <3944@m2-net.UUCP> <8053@cbmvax.UUCP> <19086@ut-emx.UUCP>
Sender: usenet@udel.EDU
Reply-To: new@udel.edu (Darren New)
Organization: University of Delaware
Lines: 22

As far as I know, in Lattice C only automatic variables
live on the stack.  If there are other things on the
stack, you would have to change the run-time support
or maybe even the compiler in order to eliminate them.
Keeping large buffers off the stack is the easiest
way to cut stack usage.  However, it usually isn't
worth it unless you can cut the stack size
down to where the program will run with the default 
stack size (4K, I think), as the user will have to
set the stack anyway.  Usually the run-time routines and
the OS and libraries and ... will use some stack too,
but I don't remember how much; usually a few hundred
bytes is enuf for well-designed libraries. The secret is
to calculate and KNOW how much stack you need.
Just look at the nesting tree for your program and
add up all the automatic space used (plus alignment
and such) and find the branch that uses the most
stack space. That (plus a few K) is how big to make
your stack.  For recursive functions, you will need to
add some for the automatic variables of the recursive
function.  But basically, in C, automatic variables
are what use stack space.   -- Darren