void func() {
// declare some variables
// do some processing
// Calculate the stack size used so far
// declare some more variables
// Calculate the stack size again used so far
}
Does the compiler stores all the variables sequentially in the stack?
void func (void)
{
int numStackBytes;
{
// declare a bunch of variables
{
int topOfStack;
numStackBytes = (((char *) &topOfStack) - ((char *) &numStackBytes)) - sizeof (numStackBytes);
}
}
}
Is that accurate? I thought the compiler was free to rearrange allocations to prevent padding when possible. (Comp Org was a few years ago, and I wasn't the most attentive, so I may certainly be off-base!)