用 C 编写一个可移植函数(无需汇编),返回其堆栈帧的大小
int stackframe_size()
{
}
尝试如下解决 - 使用 VS 2010 编译时,此函数返回 228 个字节。有没有办法验证它的正确性?
int stackframe_size(int run)
{
int i ;
if(!run)
{
return ((int)(&i) - stackframe_size(++run));
}
return (int)(&i);
}
调用为:
int main()
{
printf("\nSize of stackframe_size() is: %d bytes",stackframe_size(0)) ;
return 0;
}