> Thanks Jan, you have been a great help..how do I set the stack pragma to
compile these critical functions?
Write the following line (you may select a lower threshold than 300 By) to
the source file (*.c) start or just before the function of interest.
#pragma warn_stack_usage 300
> However, it's still giving me a warning saying that I am 'close' to
overflowing the stack
You solved it for the time being, but it is still dangerous. Maybe you do
some change to your code in the future or the program will run on a weaker
machine with less stack space or some hack will be in the call sequence
taking part of the stack. (Other experts could judge it better...) I would
still try to decrease your stack usage.
Looks like you identified the dangerous places = the mentioned struct
instances. What about to allocate them on the heap (MemPtrNew) instead of
leaving them on the stack?
Roughly speaking stack usage in a particular function = sum of sizeof's for
all local variables. This isn't an exact statement as the compiler may do
its own decisions, but it is a good estimate.
Example:
int A()
{
char bufA[1024] ;
int a ;
//...
}
int B()
{
char bufb[1024] ;
double b ;
//...
// (1)
A() ; // (2)
// (3)
}
(1), (3) A() takes (roughly) 1026 By of the stack,
(2) During the call 1026+1032 By of the stack space are taken.
Jan
----- Original Message -----
From: <[EMAIL PROTECTED]>
To: "Palm Developer Forum" <[EMAIL PROTECTED]>
Sent: Tuesday, August 24, 2004 8:02 PM
Subject: Re: stack overflow error
> Thanks Jan, you have been a great help..how do I set the stack pragma to
compile these critical functions?
>
> ...I found a way to somewhat resolve the problem. I have 3 fairly large
structs (about 60 variables). When I try to store all the data in one form,
thats when it gives me the stack overflow error. So I created another save
form and stored data to 2 of the large structs there, and it didnt give me
the error. However, it's still giving me a warning saying that I am 'close'
to overflowing the stack, but the program is still running fine on the palm
device....I would still like to know how to check for functions that are
overflowing the stack however for my own knowledge. I've never really tried
to debug in a low source level.
>
> --
> For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/