Re: How function works internally
- From: "kondal" <kondal04@xxxxxxxxx>
- Date: 27 Sep 2006 21:37:15 -0700
Keith Thompson wrote:
marydeepthy@xxxxxxxxx writes:
I would like to know what happens internally when a c programme is
executed. LIke, when we call a function, all the previous values
will be pushed on to stack and the local variables of that
particular function will be pushed in to the stack. when the
function returns, all the local variables will be poped out..
like this, what happens when we call a strcpy function. what happens in
stack??
This is not defined by the language, and different compilers can and
do handle this differently.
Not every implementation has a "stack", in the sense of a contiguous
region of memory that grows in a particular direction. There are
implementations that do the equivalent of a heap allocation to
allocate memory for a function call.
There are de facto standards for some systems. I think what you're
looking for is an ABI (Application Binary Interface, I think).
Searching for that might give you some information -- but keep in mind
that anything you find will be system-specific.
If you want to know what the language actually requires, you can get
the latest draft of the ISO C standard by search for "n1124.pdf".
(It's definitely not light reading.)
--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Could you please tell me which compiler does a heap allocation for a
function call. I haven't heard of it and I feel its interesting to
know. Any document/paper would be sufficient.
-kondal
.
- Follow-Ups:
- Re: How function works internally
- From: Keith Thompson
- Re: How function works internally
- References:
- How function works internally
- From: marydeepthy
- Re: How function works internally
- From: Keith Thompson
- How function works internally
- Prev by Date: Re: the difeirent bettwen the function open() with two an three parameters
- Next by Date: Re: How function works internally
- Previous by thread: Re: How function works internally
- Next by thread: Re: How function works internally
- Index(es):
Relevant Pages
|