Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Function arguments ("parameters") need not be stored at all. Remember: C uses <em>call by value</em>. A value need not be stored in a memory location, it could live in a register, or its value may be concluded from the program state in some way.</p> <p>For example, library functions like strlen() or sin() , cos(), sqrt() could be implemented in hardware. sin(x) <em>could</em> be implemented by storing some value(s) that correspond to <code>x</code> into special-function registers, issuing a special-function instruction and pulling the result out. (floating point hardware sometimes even has pseudo-instructions to represent for instance Pi in the best possible precision. The Pi value is never passed, only the instruction: "use Pi/2")</p> <p>Even for "normal" user-defined functions, the arguments could be passed via registers, multiple arguments <em>could</em> be combined into a large register, maybe even optimised out.</p> <p>This is best visible with inlined functions, these can totally disappear, because their functionality has been combined with that of the caller.</p> <p>Things get different when the function takes the address of one of its arguments (for instance <code>int func(int arg) { int *p = &amp;arg; }</code> will force arg to have an address), but this case is relatively rare.</p> <p>WRT the standard: a C function has an <em>activation record</em>. (Non-standard people would probably call it a "stack frame"). And the function behaves <em>as if</em> the arguments are part of its local variables, and they go out of scope once the function returns. <em>How</em> they get their values is totally irrelevant, theoretically it could even be done by message passing. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload