C calling conventions and passed arguments

后端 未结 4 1000
-上瘾入骨i
-上瘾入骨i 2021-01-06 05:35

When making a function call in Linux (or OS X for that matter), can the callee modify the values of the arguments on the stack? I was under the assumption that since the ca

4条回答
  •  再見小時候
    2021-01-06 06:10

    In standard C, the callee can modify the values of its arguments all it wants, but the caller will never see the changes.

    What may be confusing is that if one passes a POINTER to a value, then the callee can change that value by dereferencing the pointer, but if the callee actually changes the pointer itself the caller will not see that change.

    A small nit: the C standard does not require that the implementation even HAVE a stack.

提交回复
热议问题