By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,503 Members | 1,615 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,503 IT Pros & Developers. It's quick & easy.

(part 16) Han from China answers your C questions

P: n/a
memory used while declaring function

c.***********@gmail.com said:
Is there any memory allocated in stack when declaring a function
e.g void fun(int a,int b,int c);
Is it true that compiler reserves 3 stack spaces for parameters a ,b
and c....
Pushing the three arguments on a stack is one way of implementing
a function CALL (but not the only way).

As for function DECLARATIONS, I would say no. However, I can't
think of any reasons why a compiler COULDN'T pre-allocate some space
SOMEWHERE for AT LEAST ONE invocation of the function. Think about
why I said "AT LEAST ONE". What happens to the arguments in the
following cases?

fun() ---fun()
fun() ---scrotum() ---fun()
Yours,
Han from China

Nov 13 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
In article <ce******************************@dizum.com>,
Nomen Nescio <no****@dizum.comwrote:
>As for function DECLARATIONS, I would say no. However, I can't
think of any reasons why a compiler COULDN'T pre-allocate some space
SOMEWHERE for AT LEAST ONE invocation of the function.
In languages that didn't allow recursion (e.g. old Fortran), it was
common to allocate fixed locations for the arguments and local
variables of functions. In effect, you could make all variables
static by renaming.

-- Richard
--
Please remember to mention me / in tapes you leave behind.
Nov 13 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.