Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stack frame of a function

Status
Not open for further replies.

softking

Programmer
Feb 13, 2005
3
IN
Hi suppose i have a following program.
void f ()
{
int a;
{
int a;
}
}

int main ()
{
return 0;
}

Now my question is, where the two variables
int a, from where memory is given to them.
second i would like to see the stack view for the same.
how can i see it?
 
Strinctly speaking, no any memory allocation for a vars in the snippet above: no any reference to f() in the program and a (clever) linker may ignore f() code at all.
Suppose you have:
Code:
int main()
{
    f();
    return 0;
}
1. int cell allocated in the stack for the 1st a var.
2. new int cell allocated in the stack for 2nd a var.
3. 2nd var cell (logically) deallocated.
4. All f() stack frame deallocated.

In practice your compiler may allocate for f() stack frame with two slots for both examples of a vars.

How can you see the stack view: it's your debugger isssue, not the C language topics...
 
If you're using gcc, then try
gcc -Wshadow prog.c



--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top