Where are Parameter variables stored in memory?

c, variables

Solution

It depends on many different things, the calling convention is the main thing to look into. This `x86` page goes into various calling conventions and how parameters are passed to a function and this reference goes over calling conventions used by various C++ compilers and platforms. In general it is either going to be on the stack of through registers.

My answer to C++ (nested) function call instructions - registers is also relevant and has some more useful links.

Problem

I am writing some code in C and when coming across a method I wondered where parameter variables were stored in memory. I know the following: global variables -> stored in code section of static static varables -> local auto variables (inside methods) -> stored on the stack local static variables -> stored on the stack local const variables -> stored on the stack Assuming my assumptions are correct. but where are parameter variables stored? ex: int *(int x, char *c); Thanks! EDIT: I know that when I malloc something, it is placed on the heap, but say I dereference the pointer to get the value at the pointer location, is that also stored in the heap or is it now in the stack?

Original source

Related problems