is this appropriate code for estimating size of the stack?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
unsignedlongint hi;
void deeplynested(){ unsignedlongint lo, len;
lo = (unsignedint) &lo;
len = hi - lo;
printf("stack is about %d bytes\n", len );
}
void main()
{
int mainvar;
hi = (unsignedlongint) &mainvar;
deeplynested();
//...
}
it returnes me 65836 bytes on my WindowsXP Home Edition
Your global variable hi is not going to be on the stack, so the result your code gives could be a bit odd (comparing the location of a stack variable with a global stored in one of the data segments)
You could look at StackWalk64 (works with 32bit as well as 64bit, see MSDN for details)