Can anyone please tell me that why the functions parameters can not be static
?
Is this the reason that function parameters are declared on Stack
and gets de-allocated when function return? There is no way to retain parameter values? Just confused. Please clarify.
Thanks.
The keyword static
can probably be seen as somewhat "overloaded".
The following usage-options are all viable:
In terms of runtime, all types of static variables are essentially the same. They all reside in the data-section of the program, and their addresses remain constant throughout the execution of the program. So the only difference between them is during compilation, in the scope of declaration:
In terms of runtime, all types of functions (static and non-static) are essentially the same. They all reside in the code-section of the program, and their addresses remain constant throughout the execution of the program. So the only difference between them is during compilation, in the scope of declaration:
As to your question, arguments are passed to a function in the stack. There is no sense in having them static
, because that would effectively place them in the data-section. And if they are located in the data-section, then the function can simply read them from there instead of having them passed to it in the stack.